With a vector defined as std::vector<std::string>
,
Wondering why the following is valid:
if ( vecMetaData[0] != "Some string" )
{
...
But not this:
switch ( vecMetaData[1] )
{
...
Visual studio complains :
error C2450: switch expression of type 'std::basic_string<_Elem,_Traits,_Ax>' is illegal
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
switch() needs an integral type (like int, char, ...)
string is not an integral type, neither does string have an implicit conversion to an integral type, so it can't be used in a switch statement
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With