Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost.typeof] Using boost::bind with BOOST_AUTO
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-06-04 19:29:01


AMDG

Roberto Giménez wrote:
> I've registered bind:
>
> #include <boost/typeof/typeof.hpp>
> #include <boost/bind.hpp>
> #include <iostream>
> #include <typeinfo>
>
> void test()
> {
> }
>
> BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::bind_t, 3);
>
> int main(int argc, char** argv)
> {
> typedef BOOST_TYPEOF_TPL(boost::bind(&test)) Type;
>
> std::cout << typeid(Type).name() << std::endl;
> }
>
> But this prints 'int', but should be: boost::_bi::bind_t<void, void(*)(),
> boost::_bi::list0>
> What's wrong?
>

A few more registrations are missing. Unfortunately, Sun CC
silently substitutes int in some places where template instantiation fails.

#define BOOST_TYPEOF_EMULATION

#include <boost/typeof/typeof.hpp>
#include <boost/bind.hpp>
#include <iostream>
#include <typeinfo>

void test()
{
}

#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::bind_t, 3);
BOOST_TYPEOF_REGISTER_TYPE(boost::_bi::list0);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::list1, 1);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::list2, 2);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::list3, 3);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::list4, 4);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::list5, 5);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::list6, 6);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::list7, 7);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::list8, 8);
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::_bi::list9, 9);

int main(int argc, char** argv)
{
    typedef BOOST_TYPEOF(boost::bind(&test)) Type;

    std::cout << typeid(Type).name() << std::endl;
}

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net