小编Val*_*ror的帖子

当 C++20 概念的名称与类类型的名称相同时会发生什么

C++ 是否定义了以下代码的行为:

template <class T>
concept C = true;

struct C {};

template <C T>
struct A {};

template <struct C T>
struct B {};

int main() {
    // when using MSVC

    C c; // error
    bool b = C<int>; // also error
                     // and can't use concept C anywhere other
                     // than the template parameter list

    constexpr struct C cc {};

    struct C c2; // ok

    A<int> a; // ok
    A<cc> a; // error

    B<cc> b; // ok

    return …
Run Code Online (Sandbox Code Playgroud)

c++ concept c++20

5
推荐指数
1
解决办法
259
查看次数

标签 统计

c++ ×1

c++20 ×1

concept ×1