How to compare boost::string_ref to std::string
boost, c++, stl, string
Solution
Honestly, I'd just avoid using `string_ref` entirely until it matures. The fact that you can't compare a `string_ref` to a `std::string` or a `const char *` out of the box should set alarm bells ringing (looks like they forgot to write a bunch of comparison operators), and worse, it doesn't look like the library received sufficient testing (e.g. bug 8067!).
Problem
I'm trying to make `boost::string_ref` working as I want to, but I'm facing a problem right now - following code does not compile: ``` #include <boost/utility/string_ref.hpp> #include <iostream> #include <string> using namespace std; int main() { string test = "test"; boost::string_ref rtest(test); cout << (rtest == "test")<<endl; } ``` and the gcc throws 30kB error log, starting with ``` source.cpp: In function 'int main()': source.cpp:10:19: error: no match for 'operator==' (operand types are 'boost::string_ref {aka boost::basic_string_ref<char, std::char_traits<char> >}' and 'const char [5]') cout << (rtest == "test")<<endl; ^ ``` How to compare `boost::string_ref` to `std::string`?