Zhi*_*ANG 6 c++ templates constexpr c++11
请考虑以下代码:
template <typename T, typename P, T P:: *s> struct H {};
struct AA { int i; };
int main()
{
typedef int AA::*PI;
constexpr PI pi = &AA::i;
H<int, AA, &AA::i> h1; // OK
// H<int, AA, pi> h2; // compile error
}
Run Code Online (Sandbox Code Playgroud)
我有成员指针pi指向AA::i.
pi是一个constexpr变量.为什么我不能将它用作模板参数,即使&AA::i直接使用也可以?