Boost logo

Boost :

From: Andrew Myers (andrew_at_[hidden])
Date: 2001-01-02 17:49:01


Lois,

I tried your suggestion. Both compilers happy with this.

Lois Goldthwaite wrote:
>
> I'm inclined to agree with MIPSPro over VC (so is Sun's 5.0 compiler,
> BTW). Isn't it supposed to check for legal constructs at the point of
> instantiation?
>
> As a matter of curiosity, did you try specifying the default template
> parameter this way:
>
> template <class T = Null >
> class Foo
> {
> public:
> Foo( T t = T() ) {}
> };
>
> VC seems equally happy with it.
>
> Lois
>
> > Message: 6
> > Date: Tue, 02 Jan 2001 14:02:11 +1030
> > From: Andrew Myers <andrew_at_[hidden]>
> > Subject: Problems compiling graph library on IRIX.
> >
> > To start with, I realise the IRIX compilers are not among the supported
> > compilers, but this might be useful for future support.
> >
> > The platform on interest is IRIX 6.5, running version 7.30 of the MIPSPro
> > compilers. I am using boost 1.19.0.
> >
> > I have two problems that have appeared.
> >
> > Problem 1
> > ---------
> >
> > The following is a stripped down piece of code that fails to compile on IRIX,
> > but compiles successfully on MSVC++ 6, (which is my other platform of interest)
> >
> > Similar code appears in boost/graph/breadth_first_search.hpp, where the
> > make_bfs_visitor function, returns a bfs_visitor object, whose constructor has a
> > default null_visitor() argument. This means libs/graph/example/bfs_basics.C does
> > not compile.
> >
> >
> > struct Null
> > {
> > };
> >
> > template <class T>
> > class Foo
> > {
> > public:
> > Foo( T t = Null() ) {}
> > };
> >
> > template <class T>
> > Foo<T>
> > MakeFoo( T t )
> > {
> > return Foo<T>(t);
> > };
> >
> > main()
> > {
> > // Bad on IRIX
> > int i = 1;
> > MakeFoo<int>( i );
> >
> > // OK on IRIX;
> > // Null i;
> > // MakeFoo<Null>(i);
> >
> > return 0;
> > }
> >
> >
> > The resulting error message is,
> >
> > cc-1387 CC: ERROR File = temp.C, Line = 9
> > No suitable conversion function from "Null" to "int" exists.
> >
> > Foo( T t = Null() ) {}
> > ^
> > detected during instantiation of class "Foo<int>" at line 23
> >
> > 1 error detected in the compilation of "temp.C".
> >
> >
> >
> > It would appear the compiler is attempting to build the Foo constructor,
> > assigning the default argument when it is not necessary, since an argument is
> > being passed.
> >
> > My suggested workaround for this would be to replace the current constructor
> > with two constructors
> >
> > class Foo
> > {
> > public:
> > Foo() {}; // Initialise member data with Null
> > Foo( T t ) {};
> > };
> >

-- 
  Andrew Myers                                                      I-SiTE 
  Senior Software Engineer                                3D Laser Imaging
  Phone: (+61 8) 8338 9222                  
  Fax  : (+61 8) 8338 9229                         
  Email: andrew_at_[hidden]                   http://www.isite3d.com.au

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