Modernes C++ programmieren

Okt 23, 2024

lst-0715-godb.cpp

//#(compile) c++; compiler:g132; options:-O3 -std=c++23; libs:-
// https://godbolt.org/z/foPadWsKs 
#include <deque>
#include <ranges>                       // C++20
// 
std::deque in{1,2,33,34,35,99};
vector dreissig(in.begin()+2, in.begin()+5);
for(auto &e : dreissig) {
    cout << e << ' ';
}
cout << '\n';
namespace vs = std::ranges::views;      // C++20
auto v = in | vs::drop(2) | vs::take(3);
vector otuz(v.begin(), v.end());
vector trente(std::from_range, in);     // C++23