2012-03-09 2 views
6

Ho tale codice:Boost variante ottenere fallire

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

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

L'errore è:

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>*) 

Cosa c'è di sbagliato qui?

+3

'#include ' –

+0

@LucDanton Grazie, è tutto. – Ockonal

+1

@LucDanton potresti rispondere alla domanda? Segnerò il tuo post. – Ockonal

risposta

7

Il particolare sovraccarico di get fornito da Boost.Variant è disponibile tramite #include <boost/variant/get.hpp>.

In alternativa, boost/variant.hpp fornisce la maggior parte se non tutte le intestazioni di Boost.Variant, ma non lo consiglierei al di fuori di piccoli programmi giocattolo. Le intestazioni a grana fine sono belle da avere.

+0

Dang, l'ho appena capito nel modo più duro e ho cercato sul web per trovare una domanda alla quale potessi rispondere;). –