VCCC  2024.05
VisualCamp Common C++ library
common.hpp
Go to the documentation of this file.
1 //
2 // Created by YongGyu Lee on 2/8/24.
3 //
4 
5 #ifndef VCCC_RANGES_VIEWS_COMMON_HPP
6 #define VCCC_RANGES_VIEWS_COMMON_HPP
7 
8 #include <type_traits>
9 
18 
19 namespace vccc {
20 namespace ranges {
21 namespace views {
22 namespace detail {
23 
24 struct common_adaptor_object : range_adaptor_closure<common_adaptor_object> {
25  private:
26  template<typename R>
27  constexpr auto call(R&& r, std::true_type /* all and common */) const {
28  return views::all(std::forward<R>(r));
29  }
30  template<typename R>
31  constexpr auto call(R&& r, std::false_type /* all and common */) const {
32  return common_view<all_t<R>>(std::forward<R>(r));
33  }
34 
35  public:
37  constexpr auto operator()(R&& r) const {
38  return call(std::forward<R>(r), conjunction<is_invocable<all_adaptor_closure, R&&>, common_range<decltype((r))>>{});
39  }
40 };
41 
42 } // namespace detail
43 
46 
49 
51 
52 } // namespace views
53 } // namespace ranges
54 } // namespace vccc
55 
56 #endif // VCCC_RANGES_VIEWS_COMMON_HPP
Adapts a given view with different types for iterator/sentinel pair into a view that is also a common...
Definition: common_view.hpp:37
constexpr VCCC_INLINE_OR_STATIC detail::common_adaptor_object common
RangeAdaptorObject.
Definition: common.hpp:48
constexpr VCCC_INLINE_OR_STATIC detail::all_adaptor_closure all
a view that includes all elements of a range
Definition: all.hpp:82
#define VCCC_INLINE_OR_STATIC
Definition: inline_or_static.hpp:9
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35
Definition: conjunction.hpp:22
Determines whether INVOKE(std::declval<Fn>(), std::declval<ArgTypes>()...) is well formed when treate...
Definition: is_invocable.hpp:77
Definition: common_range.hpp:41
helper base class template for defining a range adaptor closure object
Definition: range_adaptor_closure.hpp:96
constexpr auto operator()(R &&r) const
Definition: common.hpp:37