簡體   English   中英

boost :: remove_pointer如何工作?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM