a string literal, like "something", is a c-string. It creates a const char[N] with static storage duration where N is the number of characters plus a null terminator. That means when you do
std::vector words {"some","test","cases","here"};
What you've done is create a std::vector<const char*> since arrays can decay to pointers.
If you want a std::vector<std::string> then what you need is to use the std::string user defined literal. That would look like
using namespace std::string_literals;
std::vector words {"some"s,"test"s,"cases"s,"here"s};
and now you have actually std::strings that the compiler will use to deduce the type of the vector.
"some","test,"cases"are of std::string type? I writestd::string x = "Hello"and it works without any issue. What am I missing here?std::string myStr = "sampletext"you declare type, can't be ambiguous or something else. I suppose it passes a C-string tostd::stringconstructor and then builds anstd::string- but I am not sure about this.