c++ - std::result_of on std::bind does not compile on clang++ 3.4 -
the following code compiles using g++-4.8 doesn't when using clang 3.4.
#include <type_traits> #include <functional> struct { template <typename continuation> bool operator()( //const continuation & continuation continuation continuation ) const { return true; } }; bool f(a) { return true; } auto g(a a) -> typename std::result_of<a( decltype(std::bind(f, a)))>::type { auto continuation = std::bind(f, a); return a(continuation); } int main(int argc, char ** argv) { a; g(a); }
g++-4.8 -std=c++0x test.cpp # ok
clang++ -std=c++0x test.cpp
test.cpp:22:38: error: no type named 'type' in 'std::result_of<a (std::_bind<bool (*(a))(a)>)>' decltype(std::bind(f, a)))>::type ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ 1 error generated.
when uncomment commented line , comment following one, code compiles on both clang ang g++.
result_of prior decltype, should simplify syntax :
auto g(a a) -> decltype( std::declval<a>()( std::bind(f, a) ) )
Comments
Post a Comment