Niels Dekker - address until 2010-10-10 wrote:
I guess we'd need to add an extra constructor that would copy from T to value_initialized<T>, right? I'm not yet entirely sure about its signature... IMO, all of them have their pro's and cons. For example:
[1] value_initialized(const T&); [2] explicit value_initialized(const T&); [3] value_initialized(const T&, explicit_copy_t); [4] explicit template <class U> value_initialized(const U&); [5] template <class U> value_initialized(const U&, explicit_copy_t);
Edward Diener wrote:
I do not really understand the need for the 'explicit_copy_t' in your possibilities.
If I recall correctly, there might be some rather exotic cases where adding value_initialized(const T&) would cause ambiguity in a program that would work before. The compiler might not be able to choose between value_initialized(const T&) and value_initialized(const value_initialized&) in some rare cases. But maybe I'm wrong... If I can't find such a case before the end of the week, I'll assume that it's a non-issue :-)
You can remove the copy constructor if you want by the usual means of making it private and providing no implementation. I admit I tend to do that whenever I want to forbid copy construction ( as well as assignment ). But I rarely have to code for the vagaries of many compilers as Boost implementations have to do.
I favor 2), although 1) is fine also. I see little reason for the templated constructor in practical use, especially since the current usage of value_initialized does not consider conversions to and from the T type in any of its functionality.
It /might/ be nice to allow conversion from U to value_initialized<T> whenever there is a conversion from U to T. But if nobody needs it, let's forget option [4] and [5] for the time being.
It would be helpful if you create a ticket regarding your request: https://svn.boost.org/trac/boost/newticket
I created the ticket. BTW value_initialized is not listed among the components one can choose, although it should be, so I chose "utility" instead. Hopefully it will be assigned to you or Fernando.