![](/img/trans.png)
[英]decltype and scope resolution operator inside a function template
[英]:: scope resolution operator in front of a template function call in c++
我堅持使用模板和范圍解析運算符。 我在文件中找到了這些行,我無法弄清楚為什么我們在模板函數調用前使用::據我所知,我們只能在引用全局變量時使用::在變量前面。 任何想法都會有所幫助
#define CREATE_AND_DECODE_TYPE(Type, buffer, pType) \
::CreateAndDecodeType<Type>(buffer, pType, throwVarBindExceptions, static_cast<Type *>(NULL))
范圍解析運算符::(在開頭)強制編譯器從全局范圍中查找標識符,而沒有找到相對於當前范圍的標識符。
namespace X
{
namespace std
{
template<typename T>
class vector {};
}
std::vector<int> x; // This is X::std::vector
::std::vector<int> y; // This is the std::vector you normally expect (from the STL)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.