www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

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

↑ ↓ ← 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
↑ ↓ 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
↑ ↓ 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
↑ ↓ 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
↑ ↓ → "Walter" <walter digitalmars.com> writes:
Thanks, I can take it from here.
Dec 02 2003