tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
incrementable_traits.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ITERATOR_INCREMENTABLE_TRAITS_HPP
4#define TETL_ITERATOR_INCREMENTABLE_TRAITS_HPP
5
11
12namespace etl {
13
14namespace detail {
15template <typename T>
16concept has_difference_type = requires { typename T::difference_type; };
17} // namespace detail
18
19template <typename I>
21
22template <typename T>
24
25template <typename T>
26 requires etl::is_object_v<T>
30
31template <typename T>
32 requires detail::has_difference_type<T>
34 using difference_type = typename T::difference_type;
35};
36
37// clang-format off
38template <typename T>
39 requires(not detail::has_difference_type<T>) and requires(T const& a, T const& b) {
40 { a - b } -> etl::integral;
41 }
42struct incrementable_traits<T> {
44};
45
46// clang-format on
47
48} // namespace etl
49
50#endif // TETL_ITERATOR_INCREMENTABLE_TRAITS_HPP
The concept integral<T> is satisfied if and only if T is an integral type.
Definition integral.hpp:13
Definition adjacent_find.hpp:8
auto declval() noexcept -> add_rvalue_reference_t< T >
constexpr bool is_object_v
Definition is_object.hpp:35
TETL_BUILTIN_PTRDIFF ptrdiff_t
etl::ptrdiff_t is the signed integer type of the result of subtracting two pointers.
Definition ptrdiff_t.hpp:14
typename make_signed< T >::type make_signed_t
Definition make_signed.hpp:82
typename T::difference_type difference_type
Definition incrementable_traits.hpp:34
etl::ptrdiff_t difference_type
Definition incrementable_traits.hpp:28
Definition incrementable_traits.hpp:20