编译器无法识别标准库中的member :: type

时间:2020-06-17 21:22:13

标签: c++ templates

由于某些原因,std::invoke_result_t<T>有效,但std::invoke_result<T>::type无效。我以为它们是等效的:

template <typename T>
class BOO {
 public:
  BOO(T func) {}
  typedef std::invoke_result_t<T> returnType;  // THIS WORKS
  typedef std::invoke_result<T>::type
      returnType;  // SYNTAX ERROR IDENTIFIER 'type'

  returnType member;
};

int main() {
  BOO boo([]() { return bool(); });
}

0 个答案:

没有答案