Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2006-05-09 19:39:21

"Stephen Gross" <sgross_at_[hidden]> writes:

> 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
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

  template <class T>
  mpl::identity<T> wrap(T const&);

  typedef typeof(wrap(boost::bind(&A::foo,_1)))::type my_type;

Dave Abrahams
Boost Consulting

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at