VCCC  2024.05
VisualCamp Common C++ library
contiguous_iterator.hpp
Go to the documentation of this file.
1 //
2 // Created by cosge on 2023-12-03.
3 //
4 
5 #ifndef VCCC_ITERATOR_CONTIGUOUS_ITERATOR_HPP_
6 #define VCCC_ITERATOR_CONTIGUOUS_ITERATOR_HPP_
7 
8 #include <type_traits>
9 
23 
24 namespace vccc {
25 namespace detail {
26 
27 template<typename I, typename = void>
28 struct explicit_contiguous_requires : std::false_type {};
29 template<typename I>
30 struct explicit_contiguous_requires<
31  I,
32  void_t<decltype( vccc::to_address( std::declval<I>() ) )>
33  > : same_as<decltype( vccc::to_address( std::declval<I>() ) ), std::add_pointer_t<iter_reference_t<remove_cvref_t<I>>>> {};
34 
35 template<typename I>
36 struct contiguous_requires : implicit_expression_check<explicit_contiguous_requires, const I&> {};
37 
38 template<
39  typename I,
40  bool = random_access_iterator<I>::value /* false */
41 >
42 struct contiguous_iterator_impl : std::false_type {};
43 
44 template<typename I>
45 struct contiguous_iterator_impl<I, true>
46  : conjunction<
47 #if __cplusplus < 202002L
48  disjunction<
49 #endif
50  derived_from<ITER_CONCEPT<I>, contiguous_iterator_tag>,
51 #if __cplusplus < 202002L
52  conjunction<
53  derived_from<ITER_CONCEPT<I>, random_access_iterator_tag>,
54  LegacyRandomAccessIterator<I>
55  >
56  >,
57 #endif
58  std::is_lvalue_reference<iter_reference_t<I>>,
59  same_as<iter_value_t<I>, remove_cvref_t<iter_reference_t<I>>>,
60  contiguous_requires<I>
61  > {};
62 
63 } // namespace detail
64 
67 
68 
69 
70 
87 template<typename I>
88 struct contiguous_iterator : detail::contiguous_iterator_impl<I> {};
89 
91 
92 } // namespace vccc
93 
94 #endif // VCCC_ITERATOR_CONTIGUOUS_ITERATOR_HPP_
constexpr T * to_address(T *p) noexcept
Definition: to_address.hpp:37
void void_t
Definition: void_t.hpp:19
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35