Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the C++20 Experimental Ranges in GCC 6.2 or above?

Tags:

c++

gcc

I want to experiment with the C++20 experimental ranges library. I tried to search around to see whether it is implemented in GNU Compiler Collection (GCC) 6.2 or above but did not find any information. Is the range library implemented in GCC?

like image 313
Amani Avatar asked Mar 24 '17 13:03

Amani


2 Answers

I have not found any official documentation stating that GCC supports the experimental Ranges TS so far, so the answer seems to be negative.

As an additional note, Eric Niebler has a "reference" implementation for Ranges, you can find it on github.
The code is known to work on the following compilers:
- clang 3.6.2 (or later)
- GCC 4.9.4 (or later) (C++14 support requires GCC 5.2; C++14 "extended constexpr" support is poor before 6.1.)
- "Clang with Microsoft CodeGen" (Clang/C2) VS2015 Update 3 (or later)

like image 143
roalz Avatar answered Sep 19 '22 18:09

roalz


The Ranges library is separate from GCC, though GCC is currently the only compiler that supports Ranges. Eric Niebler’s range-v3 library is very useful, but it is very different from the Ranges TS. The library that did implement the Ranges TS is called cmcstl2, mainly written by Casey Carter, with many contributions from Eric Niebler too. It has actually existed since 2015.

This library is header-only, and you only need to add its include directory to your include path. I define a bash alias for its quick use (you may want to do something similar):

alias gconcepts='g++ -fconcepts -std=c++17 -I$HOME/cmcstl2/include'
like image 32
Yongwei Wu Avatar answered Sep 20 '22 18:09

Yongwei Wu