In c++11 we have nice uniform initialization syntax for objects. Why it does not extends to initialize non-object types as well?
Is there any syntactic ambiguity for that, or is it just some stupid question I am asking?
Example:
struct s{ int k;};
s s1{1}; //ok (object initialization)
s const& s3{3}; //ok (object initialization)
s& s2{s1}; //error (reference initialization)
A more useful example:
struct t{ t(t const& x) : k(x.k){} int k;};
struct c
{
c(t& x1,t& x2)
: s1_{x1} //error (reference initialization)
, s2_{x2} //ok (object initialization)
{}
t& s1_;
t s2_;
};
Another one :
template<class T>
T get()
{
return T{};
}
//ok (object initialization)
get<int>();
//error (void initialization? I do not know terminology for void() token equivalent)
get<void>();