Given some function void ff(); // any signature This function is callable: void rcv_f( typename std::enable_if< true, decltype(ff) >::type const &f ) {} This function template does not produce a candidate: template< class F > void rcv_f( typename std::enable_if< true, F >::type const &f ) {} This function template prints two identical lines: template< class F > void rcv_f( F const &f ) { std::cerr << typeid( typename std::enable_if< true, F >::type ).name() << std::endl; std::cerr << typeid( F ).name() << std::endl; } The problem does not occur with functors. The first example still works if trivially made into a template, so the dependent argument matters rather than the dependent context.
Please provide a short self-contained testcase, thanks.
Sorry, that was completely wrong. I thought I'd isolated a testcase with the above code plus int main() { return rcv_f<decltype(f)>(f); }, but that actually does work. It seems the problem is completely different. The testcase below suggests that decltype somehow cannot recurse in the presence of a reference to function type. #include <tuple> #include <type_traits> // aside: std::result_of belongs in <type_traits> #include <functional> // not <functional>. template< class T, class F, size_t tuple_index0 = std::tuple_size<T>::value, size_t... tuple_indexes > typename std::result_of< typename std::enable_if< tuple_index0 == 0, F( typename std::tuple_element< tuple_indexes - 1, T >::type... ) >::type >::type apply( T const &t, F f ) { return f( std::get< tuple_indexes - 1 >( t )... ); } template< class T, class F, size_t tuple_index0 = std::tuple_size<T>::value, size_t... tuple_indexes > decltype( apply< typename std::enable_if< tuple_index0 != 0, T >::type, F, tuple_index0 - 1, tuple_index0, tuple_indexes... > ( std::declval<T>(), std::declval<F>() ) ) apply( T const &t, F f ) { return apply< T, F, tuple_index0 - 1, tuple_index0, tuple_indexes... > ( t, f ); } void f() {} void g( int ) {} void h( int, int ) {} struct a { void operator()( int, int ) {} }; int main() { // these cases work: apply( std::make_tuple(), f ); apply( std::make_tuple( 0 ), g ); apply< std::tuple< int, int >, void (&)(int, int), 1, 2 >( std::make_tuple( 0, 0 ), h ); apply( std::make_tuple( 0, 0 ), a() ); // this does not: apply( std::make_tuple( 0, 0 ), h ); } Either the subject of this bug should be changed or I should open a new bug.
Ok, then please open a new PR including a *minimal* testcase.