Boost logo

Boost :

From: Loïc Joly (loic.actarus.joly_at_[hidden])
Date: 2007-08-10 07:40:05


Hello,

I would like to use a optional<T>, where T is not copy constructible,
with a default constructor (in my case, a xmlpp::Document). I read in
the doc that one way to do that is to use in_place_factories. I tried
to do so:

myInstanceTemplateDocument = boost::in_place<xmlpp::Document>();

I got the compilation error:
myFile.cpp(341) : error C2780:
'boost::typed_in_place_factory10<T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9>
boost::in_place(const A0 &,const A1 &,const A2 &,const A3 &,const A4
&,const A5 &,const A6 &,const A7 &,const A8 &,const A9 &)' : expects 10
arguments - 0 provided
        boost\utility\typed_in_place_factory.hpp(50) : see declaration
of 'boost::in_place'
myFile.cpp(341) : error C2780:
'boost::typed_in_place_factory9<T,A0,A1,A2,A3,A4,A5,A6,A7,A8>
boost::in_place(const A0 &,const A1 &,const A2 &,const A3 &,const A4
&,const A5 &,const A6 &,const A7 &,const A8 &)' : expects 9 arguments -
0 provided
        boost\utility\typed_in_place_factory.hpp(50) : see declaration
of 'boost::in_place'
myFile.cpp(341) : error C2780:
'boost::typed_in_place_factory8<T,A0,A1,A2,A3,A4,A5,A6,A7>
boost::in_place(const A0 &,const A1 &,const A2 &,const A3 &,const A4
&,const A5 &,const A6 &,const A7 &)' : expects 8 arguments - 0 provided
        boost\utility\typed_in_place_factory.hpp(50) : see declaration
of 'boost::in_place'
myFile.cpp(341) : error C2780:
'boost::typed_in_place_factory7<T,A0,A1,A2,A3,A4,A5,A6>
boost::in_place(const A0 &,const A1 &,const A2 &,const A3 &,const A4
&,const A5 &,const A6 &)' : expects 7 arguments - 0 provided
        boost\utility\typed_in_place_factory.hpp(50) : see declaration
of 'boost::in_place'
myFile.cpp(341) : error C2780:
'boost::typed_in_place_factory6<T,A0,A1,A2,A3,A4,A5>
boost::in_place(const A0 &,const A1 &,const A2 &,const A3 &,const A4
&,const A5 &)' : expects 6 arguments - 0 provided
        boost\utility\typed_in_place_factory.hpp(50) : see declaration
of 'boost::in_place'
myFile.cpp(341) : error C2780:
'boost::typed_in_place_factory5<T,A0,A1,A2,A3,A4> boost::in_place(const
A0 &,const A1 &,const A2 &,const A3 &,const A4 &)' : expects 5 arguments
- 0 provided
        boost\utility\typed_in_place_factory.hpp(50) : see declaration
of 'boost::in_place'
myFile.cpp(341) : error C2780:
'boost::typed_in_place_factory4<T,A0,A1,A2,A3> boost::in_place(const A0
&,const A1 &,const A2 &,const A3 &)' : expects 4 arguments - 0 provided
        boost\utility\typed_in_place_factory.hpp(50) : see declaration
of 'boost::in_place'
myFile.cpp(341) : error C2780:
'boost::typed_in_place_factory3<T,A0,A1,A2> boost::in_place(const A0
&,const A1 &,const A2 &)' : expects 3 arguments - 0 provided
        boost\utility\typed_in_place_factory.hpp(50) : see declaration
of 'boost::in_place'
myFile.cpp(341) : error C2780: 'boost::typed_in_place_factory2<T,A0,A1>
boost::in_place(const A0 &,const A1 &)' : expects 2 arguments - 0 provided
        boost\utility\typed_in_place_factory.hpp(50) : see declaration
of 'boost::in_place'
myFile.cpp(341) : error C2780: 'boost::typed_in_place_factory1<T,A0>
boost::in_place(const A0 &)' : expects 1 arguments - 0 provided
        boost\utility\typed_in_place_factory.hpp(50) : see declaration
of 'boost::in_place'

In my case, the class can also accept an argument in its constructor,
therefore I used :
myInstanceTemplateDocument =
boost::in_place<xmlpp::Document>(Glib::ustring("1.0"));
and it worked, but I'd like to know if I missed something, of if it's a
shortcomming of nullary in_place_factories.

Best regards,

-- 
Loïc

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