C++: nested class of a template class

后端 未结 4 2089
被撕碎了的回忆
被撕碎了的回忆 2020-12-10 13:09

Consider the following code:

template < typename T >
struct A
{
    struct B { };
};

template < typename T >
void f( typename A::B ) {          


        
4条回答
  •  清歌不尽
    2020-12-10 13:47

    typename A::B
    

    Here, T is in a nondeduced context, which means that T cannot be deduced from the function argument.

    The problem is that in the general case, there is a potentially infinite number of possible types T that could match. Consider, for example, if instead of struct B { }; you had typedef int B;.

提交回复
热议问题