1
指向成员指针作为非类型模板参数的用例是什么?实际使用指向成员非类型模板参数的指针
例如:
class X {
public:
int n;
};
template <typename T, T nontype_param>
class C
{
public:
void doSomething()
{
//what goes here to access or use nontype_param?
}
};
void test()
{
C<int X::*, &X::n> c;
c.doSomething();
}
也许与POD结构一起使用?没有一定的背景,确实很难说出任何事情。 –
类似'X x; x。* nontype_param = 42;'? – Jarod42
@Someprogrammerdude - 正是我在阅读模板时遇到的情况。真的没有比这更多的上下文,因此关于用例的问题:) – tomatoRadar