VCCC  2024.05
VisualCamp Common C++ library
transform.hpp
Go to the documentation of this file.
1 //
2 // Created by yonggyulee on 2023/01/12.
3 //
4 
5 #ifndef VCCC_RANGES_VIEWS_TRANSFORM_HPP
6 #define VCCC_RANGES_VIEWS_TRANSFORM_HPP
7 
8 #include <type_traits>
9 #include <utility>
10 
20 
21 namespace vccc {
22 namespace ranges {
23 namespace views {
24 namespace detail {
25 
27  private:
28  template<typename R, typename F, bool = conjunction<input_range<R>, copy_constructible<F>>::value /* false */>
29  struct check_range : std::false_type {};
30  template<typename R, typename F>
31  struct check_range<R, F, true>
32  : conjunction<
33  view<R>,
34  std::is_object<F>,
35  regular_invocable<F&, range_reference_t<R>>
36  >{};
37 
38  public:
39  template<typename R, typename F, std::enable_if_t<conjunction<
41  check_range<all_t<R>, std::decay_t<F>>
42  >::value, int> = 0>
43  constexpr auto operator()(R&& r, F&& fun) const {
44  return transform_view<all_t<R>, std::decay_t<F>>(std::forward<R>(r), std::forward<F>(fun));
45  }
46 
47  template<typename F, std::enable_if_t<conjunction<
49  std::is_object<std::decay_t<F>>
50  >::value, int> = 0>
51  constexpr auto operator()(F&& fun) const {
52  return range_adaptor<transform_niebloid, std::decay_t<F>>(std::forward<F>(fun));
53  }
54 };
55 
56 } // namespace detail
57 
60 
62 
64 
65 } // namespace views
66 } // namespace ranges
67 } // namespace vccc
68 
69 #endif // VCCC_RANGES_VIEWS_TRANSFORM_HPP
Definition: range_adaptor.hpp:25
Definition: transform_view.hpp:60
constexpr VCCC_INLINE_OR_STATIC detail::transform_niebloid transform
Definition: transform.hpp:61
#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
specifies that an object of a type can be copy constructed and move constructed
Definition: copy_constructible.hpp:55
specifies the requirements for a range to be safely convertible to a view
Definition: viewable_range.hpp:59
constexpr auto operator()(F &&fun) const
Definition: transform.hpp:51
constexpr auto operator()(R &&r, F &&fun) const
Definition: transform.hpp:43