I cannot understand when and how to use the new uniform initialization syntax in C++11.
For example, I get this:
std::string a{"hello world"}; // OK
std::string b{a}; // NOT OK
Why does it not work in the second case? The error is:
error: no matching function for call to ‘std::basic_string<char>::basic_string(<brace enclosed initializer list>)’
with this version of g++ g++ (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
.
And with primitive data, what syntax should I use?
int i = 5;
int i{5};
int i = {5};