opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
range_with_size_greater_than.h
Go to the documentation of this file.
1#pragma once
2
3#include <concepts>
4#include <cstddef>
5#include <ranges>
6#include <tuple>
7
8namespace osc
9{
10 namespace detail
11 {
12 template<typename T> concept HasTupleSize = requires { std::tuple_size<std::remove_cvref_t<T>>{}; };
13 template<typename T> concept HasExtent = requires { { std::remove_cvref_t<T>::extent } -> std::convertible_to<size_t>; };
14
15 template<typename T, typename = void>
16 struct SizeHelper { static constexpr size_t size = std::dynamic_extent; };
17
18 template<HasTupleSize T>
19 requires (not HasExtent<T>)
20 struct SizeHelper<T> { static constexpr size_t size = std::tuple_size_v<std::remove_cvref_t<T>>; };
21
22 template<HasExtent T>
23 struct SizeHelper<T> { static constexpr size_t size = std::remove_cvref_t<T>::extent; };
24 }
25
26 // Satisfied if `T` has a compile-time-known size greater than `N`
27 template<typename T, size_t N>
28 concept RangeWithSizeGreaterThan = std::ranges::range<T> and (detail::SizeHelper<T>::size != std::dynamic_extent and detail::SizeHelper<T>::size > N);
29}
Definition range_with_size_greater_than.h:28
Definition range_with_size_greater_than.h:13
Definition range_with_size_greater_than.h:12
Definition custom_decoration_generator.h:5
and
Definition algorithms.h:158
Definition range_with_size_greater_than.h:16
static constexpr size_t size
Definition range_with_size_greater_than.h:16