id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 1179,[boost.python] can not export a union in VC2005sp1,qiaozhiqiang@…,Dave Abrahams,"{{{ // Visual V++ 2005(8.0) sp1, union not is_class. // because there is BOOST_STATIC_ASSERT(is_class::value) in make_instance_impl // can not export union. eg, class_ // can not return_internal_reference<> when not is_class, eg, return char*, char&, union u& // delete BOOST_STATIC_ASSERT(is_class::value); of make_instance_impl, then compile OK, and work not all OK boost/python/object/make_instance.hpp template struct make_instance_impl { typedef objects::instance instance_t; template static inline PyObject* execute(Arg& x) { // must is_class ?? BOOST_STATIC_ASSERT(is_class::value || is_union::value); BOOST_STATIC_ASSERT(is_class::value); /////////////////////////////// #include using namespace boost::python; union my_u { int a; char b; char& get_ref() { return b; } char* get_ptr() { return *b; } } struct my_s { my_u u; my_u& get_ref() { return u; } my_u* get_ptr() { return &u; } }; void my_module() { //1. compile ERROR: my_u not is_class, my_u is_union, I modify one line in make_instance.hpp // BOOST_STATIC_ASSERT(is_class::value) to BOOST_STATIC_ASSERT(is_class::value || is_union::value) // and work OK, why not export an union? class_ u_class(""my_u"", init< >()); u_class.def_readwrite(""a"", &my_u::a); u_class.def_readwrite(""b"", &my_u::b); //2. compile ERROR: char not is_class, delete BOOST_STATIC_ASSERT(is_class::value), but run error u_class.def(""get_ref"", &my_u::get_ref, return_internal_reference< >()); //3. compile ERROR: char not is_class, delete BOOST_STATIC_ASSERT(is_class::value), but run error u_class.def(""get_ptr"", &my_u::get_ptr, return_internal_reference< >()); //4. compile OK, but run ERROR, I need it return a char .def(""get_value"", &my_u::get_ptr, return_value_policy()); //5. compile ERROR, char* is not a reference, I need but have no copy_non_const_pointer u_class.def(""get_copy"", &my_u::get_ptr, return_value_policy()); class_ s_class(""my_s"", init< >()); //6. compile OK, buy run ERROR: // s = my_s() // s.u.a = 100 // print s.u.a // but output s.u.a != 100 !!! // s.u.a = 100 is s.get_u().set_a(100) and get_u() not return u(is_union) by ref ? s_class.def_readwrite(""u"", &my_s::u); // 7. compile ERROR: my_u not is_class, is_union, modify BOOST_STATIC_ASSERT(is_class::value) to // BOOST_STATIC_ASSERT(is_class::value || is_union::value) s_class.def(""get_ptr"", &my_s::get_ptr, return_internal_reference<>()); s_class.def(""get_ref"", &my_s::get_ref, return_value_policy());//compile ok } }}}",Bugs,closed,Boost 1.36.0,python USE GITHUB,Boost 1.34.0,Problem,invalid,python export union,