在这个例子中`typename`是什么意思?

时间:2013-09-04 13:50:12

标签: c++ templates

我正在查看binder1st的示例实现,如下所示:

template <class Operation, class T>
  binder1st<Operation> bind1st (const Operation& op, const T& x)
{
  return binder1st<Operation>(op, typename Operation::first_argument_type(x));
}

typename Operation::first_argument_type(x)的含义是什么?我理解first_argument_type是一个类型名,但属于binary_function基类。它在我看来它是一个属于命名空间Operation的函数 - 在这种情况下,为什么typename在这里使用?

1 个答案:

答案 0 :(得分:0)

这意味着typename关键字后面的限定名称(即Operation::first_argument_type)将被解释为(从属)类型的名称。

您可以阅读关键字typename的完整说明(也有另一种不同用法)here

相关问题