Re: [Boost-bugs] [Boost C++ Libraries] #3472: Setting value_initialized<T> to a value when T is a top-level const

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3472: Setting value_initialized<T> to a value when T is a top-level const
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-01-05 21:56:31


#3472: Setting value_initialized<T> to a value when T is a top-level const
------------------------------------------------+---------------------------
 Reporter: Edward Diener <eld@…> | Owner: fcacciola
     Type: Feature Requests | Status: new
Milestone: Boost 1.41.0 | Component: utility
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: value_initialized const |
------------------------------------------------+---------------------------

Comment(by niels_dekker):

 I still think your request is very reasonable. So I have just had another
 look at your proposed patch, which adds an explicit {{{value_initialized(T
 const&)}}} constructor. But now I'm a ''little'' bit worried that the
 patch ''might'' cause some confusion or ambiguity between your proposed
 constructor and the existing copy-constructor of {{{value_initialized}}}.
 You know, a constructor with a single parameter could get ''some
 compiler'' confused, when generating an implementation-defined copy-
 constructor,
 [http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=522094
 as you have have recently reported to Microsoft]. Moreover, I believe
 there might be use cases where ambiguity would occur, even without a
 compiler bug.

 So wouldn't it be wiser to add an extra parameter to your constructor, as
 a ''tag'' (similar to {{{std::allocator_arg_t}}} in the latest [http://www
 .open-std.org/jtc1/sc22/wg21/docs/papers/2009/n3000.pdf C++0x Draft],
 section [memory]). Such a parameter might unambiguously specify that your
 constructor would ''direct-initialize'' the object, instead of doing
 value-initialization. I would propose to call the tag type
 {{{boost::direct_initialized_t}}}, and add the following lines to
 [https://svn.boost.org/svn/boost/trunk/boost/utility/value_init.hpp
 value_init.hpp]:
 {{{
   struct direct_initialized_t { };
   const direct_initialized_t direct_initialized = direct_initialized_t();
 }}}

 Your constructor could then be defined as follows:
 {{{
    explicit value_initialized(T const & arg, direct_initialized_t)
    {
      new (wrapper_address()) wrapper(arg);
    }
 }}}

 What do you think?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3472#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC