Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2003-03-25 08:56:23


Pavel Vozenilek <pavel_vozenilek_at_[hidden]> wrote in message
news:DAV17DhnpnEODaSC0YN00008038_at_hotmail.com...
>
> ----- Original Message -----
> From: "Fernando Cacciola" <fernando_cacciola_at_[hidden]>
> > > Following snippet of code fails:
> > > -----------------
> > > #include <boost/optional.hpp>
> > > #include <utility>
> > >
> > > void foo(const boost::optional<std::pair<unsigned, unsigned> >& aux =
> > > boost::optional<std::pair<unsigned, unsigned> >())
> > > {}
> > >
> > > int main() {}
> > > -----------------
> [snip]
> > Hmm..
> > I can't reproduce the problem here with the 1.30.0 release,
> > BCB6, update 4, from within the IDE.
> > Which command line options are you using?
> >
>
> The BCB flags are:
OK, I finally reproduced the problem:
It has nothing to do with compiler flags (I made a mistake when
I tried the snippet which masked the error), but it has nothing to
do with optional either :-)

The following produces the same error:

----------------
#include <utility>

void foo( std::pair<unsigned, unsigned> >& aux
           = std::pair<unsigned, unsigned> >() // (1)
        )
{}

int main() {}
-------------

Commenting line (1) we can see that the problem
is related to the default value expression.
Furthermore, adding: using std::pair ; solves
the problem.

Further investigations revleas that this is a
subtle ADL bug related to default arguments:

In the following:

------------------------------
namespace A {

  template<class T1>
  struct X {} ;

  template<class T1,class T2>
  struct Y {} ;
}

void foo ( A::X<int>& aux
             = A::X<int>() // (1)
         ) ;

void bar ( A::Y<int,int>& aux
             = A::Y<int,int>() // (2)
         ) ;

int main() {}
------------
(1) compiles
but (2) doesn't, unless "using A::Y" is added.

Fernando Cacciola


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