|
Boost Users : |
Subject: Re: [Boost-users] [value_initialized] when T is const
From: Edward Diener (eldiener_at_[hidden])
Date: 2009-09-22 23:47:24
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 :-)
>
>> 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
As a quick 'heads up', if you add a constructor to value_initialized<T>,
make sure you also remember to add the default constructor.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net