3

私はカスタマイズしようとしstd::functionており、次のコードから始めています。

#include <functional>

template <typename>
struct my_function;

template <typename R, typename... Args>
struct my_function<R(Args...)> : std::function<R(Args...)> {
  using base = std::function<R(Args...)>;

  using base::function;
}; 

int main() {
  my_function<int(int)> f = nullptr;
}

std::functionオブジェクトを取るコンストラクタstd::nullptr_tが に継承されることを期待していますmy_function。したがって、コードは正常にコンパイルされるはずです。GCC 5.2 (C++14) ではコードのコンパイルに問題はありませんが、clang 3.6 (C++14) では次のような非常に紛らわしいエラー メッセージが生成されました。

n file included from main.cpp:1:
/usr/include/c++/v1/functional:1454:41: error: no type named 'type' in 'std::__1::enable_if<false, void>'; 'enable_if' cannot be used to disable this declaration
                                        __callable<_Fp>::value &&
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:10:15: note: in instantiation of member function 'std::__1::function<int (int)>::function' requested here
  using base::function;
              ^
main.cpp:14:25: note: while substituting deduced template arguments into function template 'my_function' [with _Fp = nullptr_t]
  my_function<int(int)> f = nullptr;
                        ^
1 error generated.

これはclangのバグですか、それとも私のコードが間違っているだけですか? (非常に幸いなことに) 後者が当てはまる場合、コードをどのように修正すればよいでしょうか?

4

0 に答える 0