/ / बूस्ट संस्करण विफल हो जाता है - सी ++, बूस्ट, संस्करण

बूस्ट संस्करण असफल हो जाता है - सी ++, बूस्ट, संस्करण

मेरे पास ऐसा कोड है:

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

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

त्रुटि है:

sourceSceneComponentsJointComponent.cpp:51:96: error: no matching function for call to "get(boost::variant<b2DistanceJointDef, b2FrictionJointDef, b2GearJointDef, b2MouseJointDef, b2PrismaticJointDef, b2PulleyJointDef, b2RevoluteJointDef, b2RopeJointDef, b2WeldJointDef, b2WheelJointDef>&)"
sourceSceneComponentsJointComponent.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>*)

क्या गलत है?

उत्तर:

उत्तर № 1 के लिए 7

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

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