Boost logo

Boost :

Subject: Re: [boost] [utility/value_init] boost::value_initialized<T> direct-initialized?
From: Jeffrey Hellrung (jhellrung_at_[hidden])
Date: 2010-03-31 13:23:58


Steven Watanabe wrote:
> AMDG
>
> Niels Dekker - address until 2010-10-10 wrote:
>>> Also, your initialized<T> does not have a default constructor. This
>>> makes sense, but I'm just double-checking that this is a conscious
>>> decision and not an oversight.
>>
>> No, it's an oversight, sorry! I did not test any code from my last mail!
>>
>> BTW I'm not entirely sure if the initialized(T const&) constructor
>> would need an "explicit" keyword. What do you think? Should the
>> following be forbidden?
>>
>> boost::initialized<int> i = 42;
>>
>> If so, we might as well make it even more explicit, by adding a "tag"
>> parameter of type direct_initialized_t to the constructor, as I
>> proposed before at https://svn.boost.org/trac/boost/ticket/3472 so
>> that users would have to explicitly specify that they want
>> direct-initialization:
>>
>> boost::initialized<int> i(42, boost::direct_initialized);
>
> I'd much prefer boost::initialized to simply forward constructor arguments.
> The templated constructor should be explicit, because otherwise things
> like
>
> boost::initialized<std::vector<int> > v = 10;
>
> would compile. IMHO, it's okay if implicit
> conversions that would normally work for
> the contained type don't work, since this errs
> on the side of safety, but it isn't okay to make
> all conversions implicit.

Agreed. And I don't think the boost::direct_initialized tag is
necessary, MSVC compiler bugs be damned.

(I primarily use MSVC9 currently.)

- Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk