GCC 9.2.0 CPP compiler

Anyone installed and compiling C++ programs using GCC 9.2.0 C++ compiler?

If yes, is the following program compiles without errors?

Is the include file ranges, available with GCC 9.2.0 C++ compiler?

Thanks
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <vector>
#include <ranges>
#include <iostream>

int main()
{
   std::vector<int> ints{0,1,2,3,4,5};
   auto even = [](int i){ return 0 == i % 2; };
   auto square = [](int i) { return i * i; };

   for (int i : ints | std::view::filter(even) | std::view::transform(square)) 
   {
       std::cout << i << ' ';
   }
   return(0);
}


Above example is at bottom of following reference URL:

https://en.cppreference.com/w/cpp/ranges


Last edited on
Above program has to output squares of even # of input vector:


0 4 16
GCC 9.2.0 was released last week?

https://www.gnu.org/software/gcc/develop.html

At bottom of above link, there is a typo error in release date 2019-02-12 instead of 2019-08-12?

Compared to following URL?

https://www.gnu.org/software/gcc/releases.html




Last edited on
Friendly reminder that C++20 (and therefore <ranges>) is not formally standardized yet. No compiler will support it as the default.

Also, https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2020 does not seem to indicate that libstdc++ has C++20's <ranges> header implemented yet.

-Albatross
That's some crazy new syntax (I remember seeing in another thread as well). I see they're trying to make it look like piping in a terminal. I wonder if the syntax being like is easier for a compiler to optimize, or if the main purpose is simply to avoid having to write possibly error-prone loops.
Last edited on
AlexCantor wrote:
std::view::filter
std::view got renamed into std::views at the last committee meeting, and that cppreference example was updated 5 days before this post. How did you get a stale copy?

Ganado wrote:
That's some crazy new syntax
ranges were part of boost since 2004, though they reached more-or-less current shape only in 2009 or so, a decade ago. That's when I first used them.
Last edited on
Thank you all for your inputs.
g++ 9.2.0 is giving compilation include file error: ranges: no such file or directory.

Last edited on
Topic archived. No new replies allowed.