Boost logo

Boost :

Subject: Re: [boost] decltype and incomplete types
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2010-04-08 16:30:46


On Thu, Apr 8, 2010 at 11:01 AM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> AMDG
>
> Daniel Walker wrote:
>>>
>>>  // found in some header somewhere
>>>  struct S;
>>>  S foo();
>>>
>>> What is the "declared type" of the expression "foo()"? Obviously, it is
>>> S.
>>>
>>
>> It might seem so at first, but consider:
>>
>> struct S;
>> S foo(int);
>> int foo(S);
>>
>> The type of the call expression foo(x) depends on which function is
>> statically chosen after overload resolution. Overload resolution may
>> not succeed unless/until S is complete.
>>
>
> But the completeness of S only affects overload resolution when
> it's used as an argument.  The fact that the argument of one overload
> is the same as the result of another is irrelevant, IMHO.

True. I only meant to show that there are circumstance where
successful overload resolution may require a complete type. Here's
another example that doesn't use function arguments. One could imagine
a scenario such as

template<class T>
typename boost::enable_if<
  boost::is_pod<T>, T
>::type foo();

template<class T>
typename boost::disable_if<
  boost::is_pod<T>, int
>::type foo();

Here the type of the expression foo<S>() cannot be determined if S is
incomplete.

Daniel Walker


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