2012-03-09 14 views
6

मैं ऐसे कोड है:बूस्ट संस्करण मिल असफल

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

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

त्रुटि है:

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

क्या यहाँ गलत?

+3

'# शामिल <बूस्ट/संस्करण/get.hpp>' –

+0

@ ल्यूकडेंटन धन्यवाद, यही है। – Ockonal

+1

@LucDanton क्या आप इस सवाल का जवाब दे सकते हैं? मैं तुम्हारी पोस्ट को चिह्नित करूंगा। – Ockonal

उत्तर

7

get का विशेष अधिभार जो Boost.Variant प्रदान करता है #include <boost/variant/get.hpp> के माध्यम से उपलब्ध है।

वैकल्पिक रूप से, boost/variant.hpp Boost.Variant के सभी शीर्षकों को प्रदान नहीं करता है, लेकिन मैं इसे छोटे खिलौनों के कार्यक्रमों के बाहर अनुशंसा नहीं करता। ठीक-ठीक हेडर अच्छे हैं।

+0

डांग, मैंने बस इसे कठिन तरीके से समझ लिया और एक प्रश्न खोजने के लिए वेब की खोज की जिसे मैं जवाब दे सकता था;)। –

संबंधित मुद्दे