使用显式参数从模板化函数中调用模板化类的模板化成员

时间:2018-05-27 02:57:14

标签: c++ templates gcc c++14 dependent-name

template<int N>
struct foo {
        template<int M>
        void f(int i){}
};

template<int N>
void bar() {
        foo<N> m;
        m.f<1>(1);      // line A
}

int main(){
        bar<1>();
        foo<1> n;
        n.f<1>(1);      // line B
        return 0;
}

GCC在行A中将<视为 less-than 运算符,但不在行B中。

是否存在某种“宽松模式”,其中GCC可以像MSVC一样处理A行,这样我就不必写m.template f<1>(1)了?

0 个答案:

没有答案