Hi! Might be already described here but did not find :-(
Lets say, I have defined class with two operators (besides other f-nalty):
class MyClass
{
public:
operator bool() const;
operator const std::string() const;
}
Now, whan I use this class the way a'la:
MyClass mc;
if(mc)
{
std::string myString{ mc };
}
If I
expect that string constructed using copy operator and
const std::string operator of MyClass but this is incorrect :-(
Instead of
operator bool() const;
used and string constructed using
basic_string( std::initializer_list<CharT> ilist,
const Allocator& alloc = Allocator() );
Same happens if I write:
std::string a{true, true, true, false, true, 'a'};
or std::string b{true};
I see that this is initializer list but isn't it limited by
char type elements? Does that mean that any value that can be converted to char value is allowed here?
What I have tried:
I've played with it using
Compiler explorer and that's seems correct!?