
Can anybody please have a look at the following feature request by Edward Diener? https://svn.boost.org/trac/boost/ticket/3472 He proposed to add an explicit constructor, value_initialized(T const&), to boost::value_initialized<T>. This constructor would copy the value of its argument to the object held by value_initialized<T>.
When such a constructor would be added, an object held by value_initialized<T> might no longer be value-initialized. Instead it might be direct-initialized. Does anybody have any moral (?) objections against the idea that value_initialized<T> might hold a non-value-initialized object?
Jeffrey Hellrung wrote:
Is defining a new template class (e.g., value_or_direct_initialized<T>, or whatever) out of the question? Just a suggestion, and not confident it's a good one...
Thanks for the suggestion, Jeffrey! I like it, actually. :-) Maybe we could simply call the new template class boost::initialized<T>. I can think of two ways to implement boost::initialized<T> (and adapt value_initialized<T> accordingly): The implementation of boost::initialized could be simply copied from the old value_initialized<T>, but having an extra constructor, initialized(T const&). The new value_initialized<T> could then be implemented in terms of boost::initialized<T>: template<class T> class value_initialized { initialized<T> m_data; public: // Forwarding to m_data member functions: T const & data() const; T& data(); void swap(value_initialized &); operator T const &() const; operator T&(); }; Or boost::initialized<T> could be derived from boost::value_initialized<T>: template<class T> class initialized: public value_initialized<T> { public: initialized(T const& arg): value_initialized(arg) {} void swap(initialized &); }; In that case, value_initialized<T> would still need the extra constructor, value_initialized(T const&), but it could be declared protected. What do you think? Kind regards, Niels -- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center