Use the latest STL implementation in C++14
// All implementations are written under C++14 standard semantics
#include "preview/ranges.h"
auto map = preview::views::iota('A', 'E') |
preview::views::enumerate |
preview::ranges::to<std::map>(); // See notes about CTAD below
std::cout << map[0] << ' '
<< map[1] << ' '
<< map[2] << '\n';
// A B C
preview
is standard-conforming, and is compatible with existing STL
// Pre-C++20 iterators are fully compatible
auto floats = std::istringstream{"1.1 2.2\t3.3\v4.4\f55\n66\r7.7 8.8"};
ranges::copy(views::istream<float>(floats), std::ostream_iterator<float>{std::cout, ", "});
// Complex ranges/iterators are also compatible with both pre C++20 and
// post C++20 std::iterator_traits
auto r = preview::views::iota(0) |
preview::views::take(10) |
preview::views::filter([](auto x) { return x % 2 == 0; });
static_assert(std::is_same<
std::iterator_traits<decltype(r.begin())>::reference,
int
>::value, "");
Up to C++26 STL are available
void foo(preview::span<int>) {}
int main() {
// span with C++26 standard
foo({1, 2, 3});
preview::variant<int, float, double> v{1.0f};
v.visit([](auto x) {
// member visit(): C++26 standard
});
// views::concat
std::vector<char> v = {'h', 'e', 'l'};
std::string s = "lo, ";
preview::string_view sv = "world";
std::list<char> l = {'!'};
// hello, world!
for (auto c : preview::views::concat(v, s, sv, l)) {
std::cout << c;
}
// expected
auto process = [](preview::string_view str) -> preview::expected<int, std::string> {
return parse_number(str)
.transform([](double v) { return static_cast<int>(v); })
.transform_error([](parse_error e) {
return e == parse_error::invalid_input ? "invalid input" : "overflow";
});
};
std::cout << process("42").value_or(-1) << '\n;'; // 42
std::cout << process("inf").value_or(-1) << '\n'; // -1
}
Compiler | Minimum version tested | Maximum version tested |
---|---|---|
MSVC | 19.29.30154.0 (Visual Studio 16 2019) | 19.40.33811.0 (Visual Studio 17 2022) |
gcc | 9.5.0 | 13.1.0 |
clang | 11.1.0 | 15.0.7 |
Apple clang | 14.0.0.14000029 | 15.0.0.15000040 (Silicon) |
Android NDK | r18 (clang 7.0) | r26 (clang 17.0.2) |
Emscripten | 3.1.20 (clang 16.0.0) | latest(3.1.61) (clang 19.0.0) |
Description
: C++YY standard implemented in C++XX
: C++YY standard, not implemented yet
- If the implementation is impossible(i.e., needs compiler support / hardware info) it is marked as N/A
- Some features are working in progress
- Introduced: First introduced version
- Revision: Behavior changed/updated version
-
<algorithm>
(61/114) -
<any>
(0/5)Introduced Revision any
bad_any_cast
swap(any)
make_any
any_cast
-
<array>
(1/1)Introduced Revision to_array
-
<atomic>
(0/17) -
<barrier>
(0/1)Introduced Revision barrier
-
<bit>
(0/14)Introduced Revision endian
bit_cast
byteswap
has_single_bit
bit_ceil
bit_floor
bit_width
rotl
rotr
countl_zero
countl_one
countr_zero
countr_one
popcount
-
<charconv>
(0/5)Introduced Revision chars_format
from_chars_result
to_chars_result
from_chars
to_chars
-
<chrono>
-
<cmath>
-
<compare>
N/A -
<concepts>
-
<coroutine>
N/A -
<cstddef>
(2/2)Introduced Revision byte
to_integer
-
<exception>
Introduced Revision uncaught_exceptions
(N/A)
-
<expected>
(4/4)Introduced Revision expected
unexpected
bad_expected_access
unexpect
unexpect_t
-
<execution>
N/A -
<flat_map>
(0/4)Introduced Revision flat_map
flat_multimap
sorted_unique
sorted_unique_t
sorted_equivalent
sorted_equivalent_t
-
<flat_set>
(0/2)Introduced Revision flat_set
flat_multiset
-
<format>
Introduced Revision -
<filesystem>
N/A -
<functional>
(6/16) -
<hazard_pointer>
Introduced Revision hazard_pointer_obj_base
hazard_pointer
make_hazard_pointer
-
<iterator>
-
<latch>
Introduced Revision latch
-
<linalg>
-
<mdspan>
Introduced Revision mdspan
extents
layout_left
layout_right
layout_stride
layout_stride
submdspan
submdspan_extents
strided_slice
submdspan_mapping_result
full_extent
full_extent_t
-
<memory>
-
<memory_resource>
N/A -
<mutex>
Introduced Revision scoped_lock
-
<new>
Introduced Revision hardware_destructive_interference_size
hardware_constructive_interference_size
launder
-
<numbers>
Introduced Revision e
log2e
log10e
pi
inv_pi
inv_sqrtpi
ln2
ln10
sqrt2
sqrt3
inv_sqrt3
egamma
phi
-
<numeric>
Introduced Revision exclusive_scan
transform_exclusive_scan
inclusive_scan
transform_inclusive_scan
gcd
lcm
reduce
transform_reduce
midpoint
ranges::iota
add_sat
sub_sat
mul_sat
div_sat
saturate_cast
-
<optional>
Introduced Revision optional
bad_optional_access
std::hash<optional>
nullopt
nullopt_t
swap(optional)
make_optional
-
<random>
Introduced Revision uniform_random_bit_generator
-
<ranges>
- Notes
ranges::to
- CTAD for
Args...
may be incorrect before C++17 - Equipped with C++23 conversions(e.g.,
pair-like
->std::pair
)
- CTAD for
- Notes
-
<semaphore>
Introduced Revision counting_semaphore
binary_semaphore
-
<stop_token>
Introduced Revision stop_token
stop_source
stop_callback
nostopstate_t
nostopstate
-
<string>
Introduced Revision erase(std::basic_string)
erase_if(std::basic_string)
-
<string_view>
Introduced Revision basic_string_view
std::hash<basic_string_view>
swap(optional)
operator""_sv
-
<source_location>
N/A -
<syncstream>
Introduced Revision basic_syncbuf
basic_osyncstream
std::swap(basic_syncbuf)
-
<span>
Introduced Revision span
dynamic_extent
as_bytes
as_writable_bytes
-
<spanstream>
Introduced Revision basic_spanbuf
basic_ispanstream
basic_ospanstream
basic_spanstream
-
<thread>
Introduced Revision jthread
-
<tuple>
Introduced Revision apply
make_from_tuple
-
<type_traits>
-
<utility>
Introduced Revision as_const
in_place
in_place_t
cmp_equal
in_range
forward_like
to_underlying
nontype
nontype_t
unreachable
N/A
-
<variant>
Introduced Revision variant
monostate
bad_variant_access
variant_size
variant_alternative
std::hash<variant>
variant_npos
visit
get_if
-
<version>
Introduced Revision