1- #ifndef KANGARU5_DETAIL_SOURCE_HELPER_HPP
2- #define KANGARU5_DETAIL_SOURCE_HELPER_HPP
1+ #ifndef KANGARU5_DETAIL_SOURCE_REBIND_HPP
2+ #define KANGARU5_DETAIL_SOURCE_REBIND_HPP
33
44#include " source.hpp"
55#include " source_reference_wrapper.hpp"
1111#include " define.hpp"
1212
1313namespace kangaru {
14- namespace detail ::source_helper {
14+ namespace detail ::source_rebind {
1515 template <wrapping_source>
1616 struct rebind_wrapper {};
1717
@@ -46,14 +46,15 @@ namespace kangaru {
4646 using type = Branch<NewSource, Param>;
4747 };
4848 };
49- } // namespace detail::source_helper
49+ } // namespace detail::source_rebind
5050
5151 template <typename Source>
5252 concept transparent_rebindable_wrapping_source =
5353 wrapping_source<Source>
5454 and requires (Source source) {
5555 // Here we need to used ttype_t instead of directly using ::ttype<...>::type because GCC 12 has issues with it.
56- typename detail::utility::ttype_t <detail::source_helper::rebind_wrapper<std::remove_cv_t <Source>>,
56+ typename detail::utility::ttype_t <
57+ detail::source_rebind::rebind_wrapper<std::remove_cv_t <Source>>,
5758 std::decay_t <decltype (source.source )>
5859 >;
5960 };
@@ -70,16 +71,17 @@ namespace kangaru {
7071 transparent_rebindable_wrapping_source<Source>
7172 or stateful_rebindable_wrapping_source<Source>;
7273
73- namespace detail ::source_helper {
74+ namespace detail ::source_rebind {
7475 struct rebind_function {
7576 template <forwarded_source Wrapper> requires (rebindable_wrapping_source<std::remove_reference_t <Wrapper>> and not forwarded_reference_wrapper<Wrapper>)
76- constexpr auto operator()(Wrapper&& source, forwarded_source auto && new_leaf) const noexcept {
77+ constexpr auto operator()(Wrapper&& source, forwarded_object auto && new_leaf) const noexcept {
7778 if constexpr (stateful_rebindable_wrapping_source<std::remove_reference_t <Wrapper>>) {
7879 return std::decay_t <Wrapper>::rebind (source, new_leaf);
7980 } else if constexpr (transparent_rebindable_wrapping_source<std::remove_reference_t <Wrapper>>) {
80- using rebound = typename detail::source_helper::rebind_wrapper<std::remove_cvref_t <Wrapper>>::template ttype<
81+ using rebound = typename detail::utility::ttype_t <
82+ detail::source_rebind::rebind_wrapper<std::remove_cvref_t <Wrapper>>,
8183 decltype (operator ()(source.source , KANGARU5_FWD (new_leaf)))
82- >::type ;
84+ >;
8385 return rebound{
8486 operator ()(source.source , KANGARU5_FWD (new_leaf))
8587 };
@@ -89,9 +91,7 @@ namespace kangaru {
8991 }
9092
9193 template <forwarded_reference_wrapper Wrapper>
92- constexpr auto operator ()(Wrapper&& wrapper, forwarded_source auto && new_leaf) const noexcept {
93- // TODO: Do we need to use forwarding refs for wrappers?
94- // TODO: Do we need to unwrap references at all? Does it even make sense?
94+ constexpr auto operator ()(Wrapper&& wrapper, forwarded_object auto && new_leaf) const noexcept {
9595 decltype (auto ) unwrapped = KANGARU5_FWD (wrapper).unwrap ();
9696 return operator ()(KANGARU5_FWD (unwrapped), KANGARU5_FWD (new_leaf));
9797 }
@@ -101,7 +101,7 @@ namespace kangaru {
101101 and not rebindable_wrapping_source<std::remove_reference_t <Leaf>>
102102 and not forwarded_wrapping_source<Leaf>
103103 )
104- constexpr auto operator()(Leaf&& leaf, forwarded_source auto && new_leaf) const noexcept {
104+ constexpr auto operator()(Leaf&& leaf, forwarded_object auto && new_leaf) const noexcept {
105105 // We do not forward new_leaf here, since it may be called multiple times
106106 return new_leaf (KANGARU5_FWD (leaf));
107107 }
@@ -120,24 +120,24 @@ namespace kangaru {
120120 inline constexpr auto is_rebindable_v<Leaf> = true;
121121
122122 namespace niebloid {
123- inline constexpr auto rebind = detail::source_helper ::rebind_function{};
123+ inline constexpr auto rebind = detail::source_rebind ::rebind_function{};
124124 }
125- } // namespace detail::source_helper
125+ } // namespace detail::source_rebind
126126
127127 inline namespace niebloid {
128- using namespace detail ::source_helper ::niebloid;
128+ using namespace detail ::source_rebind ::niebloid;
129129 }
130130
131131 template <typename Source>
132- concept rebindable_source = source<Source> and detail::source_helper ::is_rebindable_v<Source>;
132+ concept rebindable_source = source<Source> and detail::source_rebind ::is_rebindable_v<Source>;
133133
134134 template <source Source, forwarded_source Leaf>
135135 using rebind_result_t = decltype (kangaru::rebind(std::declval<Source>(), std::declval<Leaf>()));
136136
137137 template <forwarded_wrapping_source Source, forwarded_source Leaf>
138- using rebind_wrapped_source_result_t = decltype (kangaru::rebind(std::declval<forwarded_wrapped_source_t <Source>>(), std::declval<Leaf>()));
138+ using wrapped_source_rebind_result_t = decltype (kangaru::rebind(std::declval<forwarded_wrapped_source_t <Source>>(), std::declval<Leaf>()));
139139} // namespace kangaru
140140
141141#include " undef.hpp"
142142
143- #endif
143+ #endif // KANGARU5_DETAIL_SOURCE_REBIND_HPP
0 commit comments