VCCC  2024.05
VisualCamp Common C++ library
possibly_const_range.hpp
Go to the documentation of this file.
1 //
2 // Created by YongGyu Lee on 3/27/24.
3 //
4 
5 #ifndef VCCC_RANGES_POSSIBLY_CONST_RANGE_HPP_
6 #define VCCC_RANGES_POSSIBLY_CONST_RANGE_HPP_
7 
8 #include <type_traits>
9 
14 
15 namespace vccc {
16 namespace ranges {
17 namespace detail {
18 
19 template<typename R>
20 constexpr auto& possibly_const_range_impl(R& r, std::true_type) noexcept {
21  return const_cast<const R&>(r);
22 }
23 
24 template<typename R>
25 constexpr auto& possibly_const_range_impl(R& r, std::false_type) noexcept {
26  return r;
27 }
28 
29 } // namespace detail
30 
33 
35 constexpr auto& possibly_const_range(R& r) noexcept {
36  return detail::possibly_const_range_impl(r, conjunction<constant_range<const R>, negation<constant_range<R>>>{});
37 }
38 
40 
41 } // namespace ranges
42 } // namespace vccc
43 
44 #endif // VCCC_RANGES_POSSIBLY_CONST_RANGE_HPP_
constexpr auto & possibly_const_range(R &r) noexcept
Definition: possibly_const_range.hpp:35
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35
Definition: conjunction.hpp:22
Definition: negation.hpp:23
specifies the requirements for a range to be safely convertible to a view
Definition: constant_range.hpp:53