Boost logo

Boost :

Subject: Re: [boost] decltype and incomplete types
From: Eric Niebler (eric_at_[hidden])
Date: 2010-04-09 18:46:55


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.

-- 
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