【问题标题】:Concept not being recognised概念未被识别
【发布时间】:2021-03-12 00:16:03
【问题描述】:

我正在使用以下版本的clang

Apple clang version 12.0.0 (clang-1200.0.32.27)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

我收到以下代码的错误:

error: unknown type name 'IntegralType'
template <IntegralType T>
          ^

#include <iostream>
#include <type_traits>

template <typename T> concept IntegralType = std::is_integral<T>::value;

template <IntegralType T>
T func(T a)
{
    return a * a;
}

int main(int argv, char* args[])
{
    auto result = func(10);

    std::cout << result << std::endl;
}

我的CMake 文件:

cmake_minimum_required(VERSION 3.15)
project(concepts)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_executable(concepts main.cpp)

这个语法有问题,还是 AppleClang 还不支持的东西,或者其他什么?

【问题讨论】:

    标签: c++ macos clang c++20


    【解决方案1】:

    根据cppreference compiler support page,目前还没有任何版本的 Apple Clang 支持概念。

    【讨论】:

      猜你喜欢
      • 2011-06-07
      • 1970-01-01
      • 1970-01-01
      • 2012-02-28
      • 2013-04-10
      • 2016-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多