|
Boost : |
Subject: Re: [boost] [Config] Patch: clang implemented N3276 decltype
From: Eric Niebler (eric_at_[hidden])
Date: 2012-03-07 00:38:45
On 3/6/2012 9:28 PM, Daniel Walker wrote:
>
> On Mar 6, 2012, at 11:59 PM, Eric Niebler wrote:
>
>> On 3/6/2012 8:45 PM, Daniel Walker wrote:
>>> On Mar 6, 2012, at 11:09 PM, Eric Niebler wrote:
>>>
>>>> On 3/6/2012 6:27 PM, Daniel Walker wrote:
>>>>> On Mar 6, 2012, at 9:04 PM, Eric Niebler wrote:
>>>>>> On 3/6/2012 5:10 PM, Michel Morin wrote:
>>>>>>> BTW, BOOST_NO_DECLTYPE_N3276 needs to be a more descriptive name?
>>>>>>
>>>>>> I couldn't think of a better name, and
>>>>>> BOOST_NO_DECLTYPE_ON_FUNCTION_CALL_EXPRESSION_FORCES_TYPE_COMPLETENESS
>>>>>> is too long.
>>>>>>
>>>>>> :-P
>>>>>
>>>>> How about BOOST_NO_INCOMPLETE_DECLTYPE?
>>>>
>>>> Ambiguous. Does that mean that decltype support is incomplete or that
>>>> decltype doesn't force type-completeness?
>>>
>>> BOOST_NO_INCOMPLETE_DECLTYPE means the compiler does not support incomplete decltypes; i.e. it does not support decltype expressions that are incomplete types.
>>
>> But that's not the issue. The issue is this:
>>
>> template<typename T> struct S {};
>> template<typename T> S<T> fun(T) {}
>> typedef decltype(fun(0)) Si_t; // HERE
>>
>> Does the third line force the instantiation of S<int>?
>>
>> Decltype works just fine on incomplete types in the simple case, so far
>> as I know:
>>
>> struct S;
>> extern S s;
>> typedef decltype(s) S_t; // OK
>
> Oh yeah, I forgot this only comes up with call expressions. How about BOOST_NO_INCOMPLETE_DECLTYPE_CALL_EXPRESSIONS? The macro means the compiler does not support incomplete decltypes of call expressions.
That's better, I suppose. It's not 100% accurate to say that the
compiler doesn't support incomplete call expressions, though. If a
compiler doesn't implement N3276, it still supports incomplete call
expressions and usually gets the right answer, but it could potentially
instantiate a template unnecessarily in the process. (And this could set
off an infinite cascade of such template instantiations, which causes
your computer to catch fire and burn off your eyebrows.)
So I dunno. I still lean toward BOOST_NO_DECLTYPE_N3276 because nothing
pithy seems to really get at the gist of it. And I don't expect this
macro to be used outside of Boost itself. But I don't have a strong
feeling about it.
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk