The unified initializer used in the default argument for the const reference

Is this legal C ++ 0x syntax?

class A
{
public:
    void some_function( const std::set<std::string> &options = {} );
    // note that this is legal, which binds the const reference to a temporary:
    void some_function( const std::set<std::string> &options = std::set<std::string>() );
}

Because if that is the case, I just discovered an error in GCC 4.6.

The error I am getting is:

error: expected primary expression before '{' token

which ... is logical ... if it was illegal.

UPDATE: . As @Kerrek showed, this leads to simple C ++ 03, with aggregates and the syntax of the old binding syntax. Why is this impossible? Is it prohibited in the standard? Or are compilers to blame? Or is it surveillance? I do not see any serious problems resolving this as an alternative to explicit constructor calls.

+5
source share
1

++ 11, , . , GCC .

+7

All Articles