[C++-sig] compile problem with stl list
David Abrahams
dave at boost-consulting.com
Wed Dec 4 16:17:20 CET 2002
"Scott A. Smith" <ssmith at magnet.fsu.edu> writes:
> Hello,
>
> I have a small test that mimicks what I want to do:
>
>
> #include <list>
> typedef std::list<double> stdlistSP; // Using typedef on STL list
>
> #include <boost/python/module.hpp>
> #include <boost/python/def.hpp>
> #include <boost/python/class.hpp>
> using namespace boost::python;
>
> BOOST_PYTHON_MODULE(simple)
> {
> class_<stdlistSP>("stdlistSP", init<int>())
> .def("push_back", &stdlistSP::push_back)
> ;
> }
>
> When I build this using MSVC++ V6 everything works fine, but when I try
> the same using Cygwin/GCC it produces the following error:
>
> simple.cpp: In function `void init_module_simple()':
> simple.cpp:13: no matching function for call to `
> boost::python::class_<stdlistSP, boost::python::detail::not_specified,
> boost::python::detail::not_specified,
> boost::python::detail::not_specified>
> ::def(const char[10], <unknown type>)'
>
> If is switch from list<double> to vector<double> it again works just fine.
> Anyone know what I need to do?
You're generally prohibited from taking the address of a standard
library function, because it might be overloaded or have optional
arguments. In this case I bet that list::push_back is overloaded.
A thin forwarding function could be wrapped instead:
void list_push_back(stdlistSP& l, double x) { l.push_back(x); }
-Dave
--
David Abrahams
dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution
More information about the Cplusplus-sig
mailing list