mclow / String-Algo

Noodling with Boost.StringAlgo
3 stars 0 forks source link

string_ref and string_view interoperability? #2

Open OlafvdSpek opened 7 years ago

OlafvdSpek commented 7 years ago

It'd be nice if string_ref and string_view could interoperate..

void f0(boost::string_ref);
void f1(boost::string_view);

int main(int argc, char* argv[])
{
    boost::string_ref sr;
    boost::string_view sv;
    f0(sr);
    f0(sv); // error
    f1(sr); // error
    f1(sv);
mclow commented 7 years ago

I think it would be much nicer if everyone would use string_view and we could get rid of string_ref. (which is the long-term plan)

OlafvdSpek commented 7 years ago

boost::string_view or std::string_view? ;)

That'd sure be nice but neither of them is available everywhere yet.

mclow commented 7 years ago

I was speaking in the context of boost, so boost::string_view. I would like to remove boost::string_ref and have everyone who is currently using that to use boost::string_view

OlafvdSpek commented 7 years ago

What about interoperability between boost::string_view and std::string_view?

#include <boost/utility/string_view.hpp>
#include <string_view>

void f0(boost::string_view);
void f1(std::string_view);

int main(int argc, char* argv[])
{
    boost::string_view a;
    std::string_view b;
    f0(a);
    f0(b); // error
    f1(a); // error
    f1(b);
}
// MSVC 2017
OlafvdSpek commented 6 years ago

@mclow ?

mclow commented 6 years ago

My general feeling is that if you have std::string_view you should use that. boost::string_view is for situations (pre-C++17, etc) where you don't have std::string_view.

OlafvdSpek commented 6 years ago

OK, so no plans for interoperability?

Fortunately std::string_view has better availability now so it's less of a problem.