C++ type/value mismatch at argument 1 in template parameter

前端 未结 1 431
借酒劲吻你
借酒劲吻你 2021-01-26 04:41

Ok so I have this code below and when I execute it I get the following error:

type/value mismatch at argument 1 in templ         


        
1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-26 05:25

    The issue is that the compiler doesn't know whether s is a type or a value. This is the case where you add typename or template, but neither of those worked when I tested. Using the full type directly in the vector does work however:

    template 
    class B: public A {
    public:
        using A::s;
        std::vector::s> v;
    };
    

    (Edit) Kept playing with it because why not, and of course typename was needed in the one place I didn't trying it: the using line. The following code also works.

    template 
    class B: public A {
    public:
        using typename A::s;
        std::vector v;
    };
    

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