www.digitalmars.com         C & C++   DMDScript  

c++ - (possibly a) bug report (or maybe an STLport bug?)

reply dan <dan_member pathlink.com> writes:
#include "state_machine.hpp"
#include "boost/mpl/list.hpp"

#include <iostream>

class base
{
};
template < typename derived >
struct base_template_derived
{
virtual std::auto_ptr< base > clone() const
{
return std::auto_ptr<base>
(
(base*)  // *** comment-out for error ***
new derived( static_cast< derived const & >(*this) )
);
}
};
struct final : base_template_derived< final > {};

//sc player.cpp -mn -C -WA -S -3 -a8 -c -gf -D_CONSOLE=1
-IG:\dm\STLport-5.0-1031\stlport -IG:\boost-1.30.2 -IG:\boost-1.30.2\boost\mpl
-IG:\boost-1.30.2\libs\mpl\example\fsm -IG:\dm\include -oplayer.obj 
//Error: g:\BOOST-1.30.2\LIBS\MPL\EXAMPLE\FSM\player.cpp(34): cannot find
constructor for class matching std::auto_ptr<>::std::auto_ptr<>(final*)
Dec 01 2003
parent reply dan <dan_member pathlink.com> writes:
template < typename derived >
struct base_template_derived
{
should have read template < typename derived > struct base_template_derived : base { I missed putting in the inheritance while simplifying the problem code. The (bug?) report still stands, though, same error is produced.
Dec 01 2003
parent reply dan <dan_member pathlink.com> writes:
//I'll just clean it up a bit:

#include <memory>

class base
{
};
template < typename derived >
struct base_template_derived
{
virtual std::auto_ptr< base > clone() const
{
return std::auto_ptr<base>
(
(base*)  // *** comment-out for error ***
new derived( static_cast< derived const & >(*this) )
);
}
};
struct final : base_template_derived< final > {};

Notice my ugly cast, which seems to fix the problem somehow.
If you comment it out, you get the error below:

//sc player.cpp -mn -C -WA -S -3 -a8 -c -gf -D_CONSOLE=1
-IG:\dm\STLport-5.0-1031\stlport -IG:\boost-1.30.2 -IG:\boost-1.30.2\boost\mpl
-IG:\boost-1.30.2\libs\mpl\example\fsm -IG:\dm\include -oplayer.obj 
//Error: g:\BOOST-1.30.2\LIBS\MPL\EXAMPLE\FSM\player.cpp(34): cannot find
constructor for class matching std::auto_ptr<>::std::auto_ptr<>(final*)

Hope it helps, and sorry to post thrice.
Dec 01 2003
parent reply dan <dan_member pathlink.com> writes:
#include <memory>

class base
{
};
template < typename derived >
struct base_template_derived : base  // *** missed in prev.post
{
virtual std::auto_ptr< base > clone() const
{
return std::auto_ptr<base>
(
(base*)  // *** comment-out for error ***
new derived( static_cast< derived const & >(*this) )
);
}
};
struct final : base_template_derived< final > {};

Notice my ugly cast, which seems to fix the problem somehow.
If you comment it out, you get the error below:

//sc player.cpp -mn -C -WA -S -3 -a8 -c -gf -D_CONSOLE=1
-IG:\dm\STLport-5.0-1031\stlport -IG:\boost-1.30.2 -IG:\boost-1.30.2\boost\mpl
-IG:\boost-1.30.2\libs\mpl\example\fsm -IG:\dm\include -oplayer.obj 
//Error: g:\BOOST-1.30.2\LIBS\MPL\EXAMPLE\FSM\player.cpp(34): cannot find
constructor for class matching std::auto_ptr<>::std::auto_ptr<>(final*)

Hope it helps, and sorry to post... 4 times ... :(
Dec 01 2003
parent "Walter" <walter digitalmars.com> writes:
Thanks, I can take it from here.
Dec 02 2003