【发布时间】: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 还不支持的东西,或者其他什么?
【问题讨论】: