[boost.typeof] Using boost::bind with BOOST_AUTO
I have the following code: #include <boost/typeof/typeof.hpp> #include <boost/bind.hpp> void test() { } int main(int argc, char** argv) { BOOST_AUTO(a, boost::bind(&test)); } But when I try to compile, I get errors: CC -m64 -erroff=wvarhidemem,hidevf,hidevfinvb -errtags=yes -library=stlport4 -mt -c -g -I/home/gimenero/include -o build/Debug/Sun12-Solaris-Sparc/main.o main.cc CC -m64 -erroff=wvarhidemem,hidevf,hidevfinvb -errtags=yes -library=stlport4 -mt -c -g -I/home/gimenero/include -o build/Debug/Sun12-Solaris-Sparc/main.o main.cc "main.cc", line 11: Error, nomatchoverin: Could not find a match for boost::type_of::encode<boost::type_of::V, boost::type_of::T> (boost::_bi::bind_t<void, void(*)(), boost::_bi::list0>) needed in main(int, char**). "main.cc", line 11: Error, nomatchoverin: Could not find a match for boost::type_of::encode<boost::type_of::V, boost::type_of::T> (boost::_bi::bind_t<void, void(*)(), boost::_bi::list0>) needed in main(int, char**). "main.cc", line 11: Error, nomatchoverin: Could not find a match for boost::type_of::encode<boost::type_of::V, boost::type_of::T> (boost::_bi::bind_t<void, void(*)(), boost::_bi::list0>) needed in main(int, char**). ... many times. Does BOOST_AUTO supports boost::bind?
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? "Steven Watanabe" <watanabesj@gmail.com> escribió en el mensaje news:4A2826F2.4060704@providere-consulting.com... AMDG Roberto Giménez wrote:
<snip>
Does BOOST_AUTO supports boost::bind?
In emulation mode, Boost.Typeof only has builtin support for standard and built in types. Other types need to be registered. In Christ, Steven Watanabe
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
That solved my problem. Thanks! "Steven Watanabe" <watanabesj@gmail.com> escribió en el mensaje news:4A2858BD.3050704@providere-consulting.com... 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
Hi Steven, Steven Watanabe wrote:
AMDG
Roberto Giménez wrote:
I've registered bind:
[snip typeof support for bind] This looks like a generally useful feature to be included in boost. Can this (with necessary modifications, of course) be added in the form of a new optional header boost/bind/typeof.hpp ? Best Regards, Gevorg
AMDG Gevorg Voskanyan wrote:
Steven Watanabe wrote:
AMDG
Roberto Giménez wrote:
I've registered bind:
[snip typeof support for bind]
This looks like a generally useful feature to be included in boost. Can this (with necessary modifications, of course) be added in the form of a new optional header boost/bind/typeof.hpp ?
You can create a ticket at svn.boost.org. Otherwise, it's likely to get lost. In Christ, Steven Watanabe
Steven Watanabe wrote:
Gevorg Voskanyan wrote:
[snip]
Can this (with necessary modifications, of course) be added in the form of a new optional header boost/bind/typeof.hpp ?
You can create a ticket at svn.boost.org. Otherwise, it's likely to get lost.
Done. https://svn.boost.org/trac/boost/ticket/3139 I added the necessary registrations to support non-nullary functions and placeholders as well. Best Regards, Gevorg
participants (3)
-
Gevorg Voskanyan
-
Roberto Gim�nez
-
Steven Watanabe