
"Stephen Gross"
I just found out about the typeof feature in g++. I'm trying to use the type returned by a boost::bind invocation. Is there any way to make the following work:
=============================== struct A { int foo(); } typedef typeof(boost::bind(A::foo)) my_type; ===============================
So far, g++ just seg faults on me. Am I doing something horribly wrong, or is this (more likely) not possible in the first place?
Syntax errors aside, g++'s typeof is notoriously broken. Libraries like BOOST_TYPEOF (http://engineering.meta-comm.com/resources/cs-win32_metacomm/doc/html/typeof...) add special hacks to get around this. Usually you can do something like wrap the result in a wrapper template, and pull the type out of that: template <class T> mpl::identity<T> wrap(T const&); typedef typeof(wrap(boost::bind(&A::foo,_1)))::type my_type; -- Dave Abrahams Boost Consulting www.boost-consulting.com