|
Boost : |
Subject: Re: [boost] [chrono] Interoperability with ICL and common concepts
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2011-03-16 11:37:35
Joachim Faulhaber wrote:
>
> 2011/3/16 Howard Hinnant <howard.hinnant_at_[hidden]>:
>> On Mar 16, 2011, at 8:50 AM, Joachim Faulhaber wrote:
>>
>>> 2011/3/15 Howard Hinnant <howard.hinnant_at_[hidden]>:
>>>> On Mar 15, 2011, at 2:00 PM, Vicente Botet wrote:
>>>>
>>>> The current std::chrono::duration default constructor has this
>>>> definition:
>>>>
>>>> constexpr duration() = default;
>>>
>>> hmm, I'm a little confused now
>>>
>>>> The rationale for this is to give the client and the Rep author as many
>>>> options as possible:
>>>>
>>>> typedef std::chrono::duration D;
>>>>
>>>> D d1; Â // d1.count() uninitialized - speed
>>>> D d2 = D(); Â // d2.count() zero-initialized - safety if you believe 0
>>>> is safe
>>>
>>> This behavior is exactly what I desire
>>>
>>>> typedef std::chrono::duration CustomD;
>>>>
>>>> CustomD d3; Â // d3.count() default constructed
>>>
>>> But the current implementation of Boost.Chrono does not work like that:
>>>
>>> typedef std::chrono::duration D;
>>> D d2 = D(); Â // d2.count() UNINITIALIZED
>>>
>>> Will the semantics of
>>>
>>>> constexpr duration() = default;
>>>
>>> implement the proposed behavior with the new standard?
>>
>> Yes. Â I'm not sure if any compiler yet implements =default for default
>> constructors. Â I'm hopeful that this feature will be widely implemented
>> soon. Â It has the semantics of defining a compiler-generated default
>> constructor, which you can only do in C++03 if you don't have any other
>> constructors declared.
>
> That's good to hear, so my wishes for durations default ctor behavior
> will be fulfilled at least in the future.
>
>>>> D d2 = D(); // d2.count() zero-initialized - safety if you believe 0
>>>> is safe
>
Howard I have see this behavior with enum classes. It toke me a while to
understand why the two preceding assignments results in different values,
but after that it is the same as
int i;
int j= int();
It is extraneous however :(
Joachim, it seems that you have found a Bug on the emulation of =default
Boost.Chrono does. Please could you create a ticket.
I think that the user could survive to a duration that is initialized to 0
even when the user has not requested it.
Best,
Vicente
-- View this message in context: http://boost.2283326.n4.nabble.com/chrono-Interoperability-with-ICL-and-common-concepts-tp3357088p3382111.html Sent from the Boost - Dev mailing list archive at Nabble.com.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk