lundi 20 avril 2015

Shouldn't standard specializations of std::atomic lack value constructor

The general version of the std::atomic template has a value constructor declared as

constexpr atomic( T desired ); (See here)

It is also said that bool, integral and pointer specializations of the template have (quoted from cppreference)

standard layout, trivial default constructors, and trivial destructors. They support aggregate initialization syntax.

This makes sense, for classes having only trivial default ctor and dtor (i.e., without a value ctor) qualifies as an aggregate and hence supports aggregate initialization syntax. However, the following code compiles fine on both GCC and clang:

std::atomic_int i(9);

This implies that a value ctor should exist. Is this a violation of the standard?

Aucun commentaire:

Enregistrer un commentaire