这个模板函数的类型要求是什么
What are the requirements on type for this template function
我看到的C++代码如下:
template<class A>
bool foo(int A::*)
{ /*blah*/ }
什么是int A::*
结构?它对A
型有什么要求?
非常感谢!!
int A::*
是指向A
类型的int
数据成员的指针。例如,给定类型:
struct Foo { int i; };
struct Bar { double d; };
int Foo::*
是指向Foo
类型的int
数据成员的指针,其唯一有效值为null和Foo::i
的地址int Bar::*
是指向Bar
类型的int
数据成员的指针,其唯一有效值为null,因为Bar
不包含int
数据成员
对类型A
的唯一要求是它不是基元类型,因为基元类型显然不能有数据成员。
相关文章:
- 标准 N3337 5.2.10 第 7 条中的C++"类型"是什么意思?
- 如何声明一个标准::提升直方图的向量?提升直方图的类型是什么?
- 类名后跟括号的类型是什么
- std::chrono::duration::count函数的实际结果类型是什么
- c++运算符重载-我实际返回的操作数类型是什么
- 运算符和返回类型是什么意思?
- 指向 2D 数组的指针的类型是什么?
- RSA_verify中预期的数据类型是什么,无法验证从 Java 生成的签名
- 共享_ptr中多功能数组的类型是什么
- 构造函数的类型是什么?
- 字符串中单个字符作为数组的数据类型是什么
- 该结构继承的类型是什么
- 如果我获得Integer和Double的产品,输出的数据类型是什么
- C 中被视为可可的类型是什么
- 当函数采用右值引用时,函数中该变量的类型是什么?
- STD :: SETW,STD :: SETFILL等的真实返回类型是什么?
- 模板类中引用的引用的类型是什么
- const自动参考绑定到(NULL)指针 - 实际类型是什么
- 包含通过引用捕获的 lambda 函数的"variable"的类型是什么?
- 通过插座发送的内容的数据类型是什么