英文:
What's the offical name of using function call operator as template argument
问题
我试图使用类型特性与函数对象,以下是代码:
struct fun {
  template <class T>
  constexpr auto operator()(T a) const  {
    return 0;
  }
};
template<class T> 
struct types{};
我好奇types<fun(int)>的官方名称是什么,可能是获取函数调用运算符的类型吗?
英文:
I'm trying to use type trait with functor, below is the code:
struct fun {
  template <class T>
  constexpr auto operator()(T a) const  {
    return 0;
  }
};
template<class T> 
struct types{};
I'm curious about what's the official name of the usage types<fun(int)>, probably getting the type of the function call operator?
答案1
得分: 1
fun(int) 是一个接受 int 并返回 fun 类型的函数类型。
它与 fun::operator() 无关。
英文:
fun(int) is the type of a function that takes an int and returns a fun.
It is unrelated to fun::operator().
答案2
得分: 1
"types<fun(int)>"被称为模板标识:
模板标识由两个部分组成:
- 
模板名称:在您的示例中为
types。 - 
参数列表:在您的示例中为
fun(int),它本身是一个函数类型。 
英文:
> what's the official name of the usage types<fun(int)>
It (types<fun(int)>) is called a template-id:
> <h4>template-id</h4>
>
> 
> template-name <parameter-list >
> 
As you can see the template-id consists of 2 parts:
- 
template-name: which is
typesin your example. - 
parameter-list: which is
fun(int)which itself is a function type in your example. 
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论