[英]How does boost::remove_pointer work?
因此remove_reference或remove_pointer始终返回基本类型。
我知道他们在模板元编程中使用所谓的模板特化来做到这一点,但我不太明白。
例如下面。
template<class T>
struct AAA
{
typedef T Type;
};
template<class T>
struct AAA<T*>
{
// Why does T become int, not int * all of sudden?
// How come does this get rid of '*' in a specific way?
typedef T Type;
};
int main()
{
AAA<int *>::Type MyVar = 3; // MyVar is not a pointer!
return 0;
}
显然我在使用模板时遗漏了一些东西,或者一些指定的规则,我找不到任何能很好地解释这个问题的好文章。
任何帮助,将不胜感激。
谢谢,谢谢。
// Why does T become int, not int * all of sudden?
T*
是int*
,所以T
必须是int
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.