[C++-sig] wrapping typedef equivalent types

David Abrahams dave at boost-consulting.com
Thu Oct 20 18:07:51 CEST 2005


"Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> writes:

> FWIW, I've used something like the following in a few places:
>
>         .def("set_selected",
>           (object(*)(
>             object const&,
>             af::const_ref<std::size_t> const&,
>             e_t const&)) set_selected_unsigned_s)
>       ;
>       if (   boost::python::type_info(typeid(af::const_ref<std::size_t>))
>           != boost::python::type_info(typeid(af::const_ref<unsigned>))) {
>         result
>           .def("set_selected",
>             (object(*)(
>               object const&,
>               af::const_ref<unsigned> const&,
>               af::const_ref<e_t> const&)) set_selected_unsigned_a)
>
>
> I.e. the trick is to compare boost::python::type_info(typeid(X)).


  if ( boost::is_same< std::size_t, unsigned >() )

would be a whole lot cleaner, and would often generate less code since
the check can be made at compile-time.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list