|
Boost : |
Subject: Re: [boost] decltype and incomplete types
From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2010-04-09 19:55:45
On 04/09/2010 06:46 PM, Eric Niebler wrote:
> On 4/9/2010 2:39 PM, Daniel Walker wrote:
>
>> So, yeah, in general, if some signature requires a type to be
>> complete, then the function can't be used in context where the type is
>> incomplete... But I can think of one counterexample. If SFINAE drops
>> the signature during template substitution, then overload resolution
>> could still succeed. So the following, I believe, is valid even though
>> S is incomplete. g++ accepts it.
>>
>> template<class T>
>> int f(typename T::foo, T x = T());
>>
>> template<class T>
>> int f(...);
>>
>> struct S;
>> typedef decltype(f<S>(0)) type;
>>
> Whoa, that's wacky. I tried comeau in strict C++03 mode, removed the use
> of decltype from this example, and confirmed that whether the type is
> complete or not actually changes which overload gets selected. I didn't
> think type completeness was a SFINAE case. This has ODR written all over
> it -- I don't know if it's valid code or not.
>
While not strictly the same, this sounds like the following would apply,
too:
14.7.1/6:
"If an implicit instantiation of a class template specialization is
required and the template is declared but not defined, the program is
ill-formed."
(Again, I understand that's not exactly the case here, but the spirit is
the same.)
Stefan
-- ...ich hab' noch einen Koffer in Berlin...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk