2012-03-09 40 views
6

tengo dicho código:variante Boost obtener fallar

boost::variant<b2DistanceJointDef, b2FrictionJointDef, 
     b2GearJointDef, b2MouseJointDef, b2PrismaticJointDef, b2PulleyJointDef, 
     b2RevoluteJointDef, b2RopeJointDef, b2WeldJointDef, b2WheelJointDef> prmJointDef; 

b2DistanceJointDef &prmDistaceJointDef = boost::get<b2DistanceJointDef>(prmJointDef); 

El error es:

source\Scene\Components\JointComponent.cpp:51:96: error: no matching function for call to 'get(boost::variant<b2DistanceJointDef, b2FrictionJointDef, b2GearJointDef, b2MouseJointDef, b2PrismaticJointDef, b2PulleyJointDef, b2RevoluteJointDef, b2RopeJointDef, b2WeldJointDef, b2WheelJointDef>&)' 
\source\Scene\Components\JointComponent.cpp:51:96: note: candidates are: 
boost/optional/optional.hpp:626:30: note: template<class T> typename boost::optional::reference_const_type boost::get(const boost::optional<T>&) 
boost/optional/optional.hpp:634:24: note: template<class T> typename boost::optional::reference_type boost::get(boost::optional<T>&) 
boost/optional/optional.hpp:644:30: note: template<class T> typename boost::optional::pointer_const_type boost::get(const boost::optional<T>*) 
boost/optional/optional.hpp:652:24: note: template<class T> typename boost::optional::pointer_type boost::get(boost::optional<T>*) 

¿Cuál es incorrecto aquí?

+3

'#include ' –

+0

@LucDanton Gracias, eso es todo. – Ockonal

+1

@LucDanton ¿podría responder la pregunta? Voy a marcar tu publicación. – Ockonal

Respuesta

7

La sobrecarga específica de get que ofrece Boost.Variant está disponible a través de #include <boost/variant/get.hpp>.

Alternativamente, boost/variant.hpp proporciona la mayoría si no todos los encabezados de Boost.Variant, pero no lo recomendaría fuera de los programas de juguetes pequeños. Los encabezados de grano fino son agradables de tener.

+0

Dang, acabo de descubrirlo por las malas y busqué en la web para encontrar una pregunta que pudiera responder;). –