小编Hym*_*sen的帖子

注入的类名称为类型

鉴于以下代码,

template <class> using void_t = void;
template <class C, class = void> struct X { enum { v = 0 }; };
template <class C> struct X<C, void_t<typename C::T> > { enum { v = 1 }; };
struct T { };
int main() { return X<T>::v; }
Run Code Online (Sandbox Code Playgroud)

什么应该主要回归?GCC和MSVC说1,Clang说0.

c++ language-lawyer c++17

14
推荐指数
2
解决办法
424
查看次数

C++ operator-comma/forward reference code无法编译

除非注释行被取消注释,否则以下代码无法编译:

template <class T> struct R { static T& r(); };
struct M {
    static char m(M&);
    template <class T> static int m(const T&);
};
template <class T> struct A;
template <class T>
struct B {
    struct U { };
    struct V { M& operator,(U); };
    enum { v = sizeof(M::m((R<V>::r(), R<A<T>*>::r()))) };
};
template <class T> struct A { B<T> y; };
int main()
{
//  A<int>();  // Works if uncommented.
    B<int>();
}
Run Code Online (Sandbox Code Playgroud)

在逗号运算符中,编译器认为它需要A<int>完成,即使代码只是在流量中A<T>*.我不明白为什么.它与clang和g ++都失败了.克朗说 …

c++

6
推荐指数
1
解决办法
154
查看次数

标签 统计

c++ ×2

c++17 ×1

language-lawyer ×1