
Alexander Nasonov wrote:
The following code doesn't compile on gcc 3.3.5
typedef int (fun)(bool); fun& foo();
BOOST_STATIC_ASSERT((boost::is_same<BOOST_TYPEOF(foo()), fun>::value));
The error is
error: no matching function for call to `ensure_obj(int(&)(bool))'
This can be fixed by introducing more specialized ensure_obj:
template<class T> T& ensure_obj(const T&, int); template<class R, class T0> R(& ensure_obj(R (&)(T0), ...) )(T0); template<class R, class T0, class T1> R(& ensure_obj(R (&)(T0,T1), ...) )(T0,T1); // ...
Sorry for jumping in here. But I believe that #ifndef BOOST_NO_SFINAE namespace boost { namespace type_of { template<typename T> typename enable_if<is_function<T>, T &>::type ensure_obj(T &); } } #endif // verified to solve the problem with GCC 3.2.3 is a much nicer solution to the problem you describe (because it leaves scalability up to boost::is_function). Best, Tobias