
8 Apr
2010
8 Apr
'10
4:30 p.m.
Stewart, Robert wrote:
Fernando Cacciola wrote:
I can imagine myself explaining that "initialize<T> m(v)" does direct-initialization, then that, OTOH, "initialized<T> m;" does value-initialization, since there is no explicit initialization in this case.
Why does initialized<T> need to have a default constructor?
Because if it wasn't default-constructible, why would you use it (when a T object would suffice)? The motivating example (I believe) is when you have a class member of type initialized<T>, and you want the default constructor of the class to value initialize the data member. (You also want a (const T&) constructor that direct intializes the data member; otherwise, value_initialized<T> would suffice.) - Jeff