如何构建支持 C++ 概念 ("concepts lite") 的 gcc?

How do I build gcc with C++ concepts ("concepts lite") support?

C++ 标准委员会正在为概念扩展制定 TS(技术规范):"Programming Languages - C++ Extensions for Concepts"。 N4377 是本文档的最新版本。为了包含在 C++ 标准功能中,要求实现,理想情况下是用于可公开访问的系统。

我知道 concept-gcc but the concepts proposal above (colloquially referred to as Concepts Lite) is different. I heard that there is a concepts branch and I have tried the origin/asutton/c++-concepts from gccgit 镜像,但没有编译。如何构建和使用支持上述 [草案] TS 中指定概念的 gcc 版本?

根据 Andrew Sutton 的说法,Concepts Lite 作品的 git 镜像已经完全过时,不应再使用。 gcc implementing "concepts-lite" (there was a pre-C++11 effort to add concepts to C++ which was abandoned; a new effort to add concepts to C++ was started using the name concepts lite). It is fairly straight forward to build (assuming you already have a recent gcc and the packages it depends on installed; see the gcc install instruction for other options you might want to pass: the instructions below worked for me except that I explicitly pointed configure at the locations where gmp, mpc, and mpfr 已安装的 svn 存储库中有一个概念分支:

cd <suitable-directory>
svn checkout svn://gcc.gnu.org/svn/gcc/branches/c++-concepts
mkdir build-concepts
cd build-concepts
../c++-concepts/configure --prefix=<concept-gcc-root> --disable-bootstrap --enable-languages=c,c++
make -j8
make install

不完全明显的是如何实际使用概念:选项-fconcepts确实存在,但似乎无条件地做一些不同于启用精简概念的事情。相反,在启用概念的情况下进行编译时,您将使用 -std=c++1z 选项。

Fri, 7 Aug 2015 01:44:49 -0400 (05:44 +0000) 开始,概念支持已合并到 gcc 的主干中。

使用之后的构建,您可以使用 -std=c++1z 标志启用概念支持。

从 gcc 6.1 (27-04-2016) 开始,概念由 -fconcepts 启用,因为它们不太可能包含在 C++17 中,因此它们已从 -std=c++1z 中删除。 (通过下面评论中的@BruceAdams)