std::result_of на std::bind не компилируется на clang++ 3.4

Следующий код компилируется с использованием g++-4.8, но не при использовании clang 3.4.

#include <type_traits>
#include <functional>

struct A {
    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 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.

Когда вы раскомментируете закомментированную строку и комментируете следующую, код компилируется на обоих языках clang и g ++.

1 ответ

result_of был до decltype, вы должны упростить синтаксис следующим образом:

auto g(A a) -> decltype( std::declval<A>()( std::bind(f, a) ) )
Другие вопросы по тегам