Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-01-24 09:14:25


attached mail follows:


"Sergey P. Derevyago" <non-existent_at_[hidden]> wrote:
> Is the following code well-formed?
> -----------------------------------8<-----------------------------------
> #include <stdio.h>
>
> struct B {};
> struct D : private B {};
>
> struct No {};
> struct Yes { No no[2]; };
>
> Yes Test(B*);
> No Test(...);
>
> int main()
> {
> printf("%d", sizeof(Test((D*)0))==sizeof(Yes));
> }
> -----------------------------------8<-----------------------------------
> It seems like it should not but some compilers don't agree.

You're right: This is an error. The first "Test" is selected
by overload resolution, but trying to bind (D*)0 to the
parameter results in an access error.

SFINAE doesn't come into play here.

         Daveed

      [ Send an empty e-mail to c++-help_at_[hidden] for info ]
      [ about comp.lang.c++.moderated. First time posters: do this! ]


-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

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