Quantcast
Channel: Why doesn't std::string have a constructor that directly takes std::string_view? - Stack Overflow
Browsing all 2 articles
Browse latest View live

Answer by BoP for Why doesn't std::string have a constructor that directly...

The ambiguity is that std::string and std::string_view are both constructible from const char *. That makes things likestd::string{}.assign("ABCDE", 0, 1)ambiguous if the first parameter can be either...

View Article



Why doesn't std::string have a constructor that directly takes std::string_view?

To allow std::string construction from std::string_viewthere is a template constructortemplate<class T>explicit basic_string(const T& t, const Allocator& alloc = Allocator());which is...

View Article
Browsing all 2 articles
Browse latest View live




Latest Images