Class Template Argument Deduction in member variables

前端 未结 1 1237
-上瘾入骨i
-上瘾入骨i 2020-12-21 08:31

Expanded version here.

We can create objects of class templates that have default template parameters without typing angle brackets:

int main()
{
            


        
相关标签:
1条回答
  • 2020-12-21 09:22

    No, it is not a bug. It is because there could be different constructors called for the same member variable (called through class' constructor init list), potentially yielding different deduction result.

    To prevent the potential for such conflict, you have to provide template arguments to non-static members. (Static members are not a problem, because there will a be a single constructor call for them)

    0 讨论(0)
提交回复
热议问题