diff --git a/include/continuable/detail/traverse.hpp b/include/continuable/detail/traverse.hpp index d242131..9450c31 100644 --- a/include/continuable/detail/traverse.hpp +++ b/include/continuable/detail/traverse.hpp @@ -691,6 +691,22 @@ class mapping_helper : protected mapping_strategy_base { return mapper_(std::forward(element)); } + /// SFINAE helper for elements satisfying the container + /// requirements, which are not tuple like. + template + auto deep_map(container_category_tag, T&& container) + -> decltype(container_remapping::remap(Strategy{}, + std::forward(container), + std::declval())); + + /// SFINAE helper for elements which are tuple like and + /// that also may satisfy the container requirements + template + auto deep_map(container_category_tag, T&& tuple_like) + -> decltype(tuple_like_remapping::remap(Strategy{}, + std::forward(tuple_like), + std::declval())); + /// SFINAE helper for plain elements not satisfying the tuple like /// or container requirements. /// @@ -709,45 +725,6 @@ class mapping_helper : protected mapping_strategy_base { -> decltype(std::declval().deep_map( category, std::forward(element))); - /// SFINAE helper for elements satisfying the container - /// requirements, which are not tuple like. - template - auto deep_map(container_category_tag, T&& container) - -> decltype(container_remapping::remap(Strategy{}, - std::forward(container), - std::declval())); - - /// SFINAE helper for elements which are tuple like and - /// that also may satisfy the container requirements - template - auto deep_map(container_category_tag, T&& tuple_like) - -> decltype(tuple_like_remapping::remap(Strategy{}, - std::forward(tuple_like), - std::declval())); - - /// Prioritize the mapper over container remapping. - /// - /// We use the proxy function invoke_mapper here, - /// because some compilers (MSVC) tend to instantiate the invocation - /// before matching the tag, which leads to build failures. - template - auto try_map(container_category_tag, T&& element) - -> decltype(std::declval().invoke_mapper( - std::forward(element))) { - // T could be any non container or non tuple like type here, - // take int or std::future as an example. - return invoke_mapper(std::forward(element)); - } - - /// Forward the input to the deep remap methods in order - /// to prioritize the mapper before deep container remaps. - template - auto try_map(Category category, T&& element) - -> decltype(std::declval().try_deep_map( - category, std::forward(element))) { - return try_deep_map(category, std::forward(element)); - } - /// Match elements satisfying the container requirements, /// which are not tuple like. template @@ -784,6 +761,29 @@ class mapping_helper : protected mapping_strategy_base { return this->may_void(std::forward(element)); } + /// Prioritize the mapper over container remapping. + /// + /// We use the proxy function invoke_mapper here, + /// because some compilers (MSVC) tend to instantiate the invocation + /// before matching the tag, which leads to build failures. + template + auto try_map(container_category_tag, T&& element) + -> decltype(std::declval().invoke_mapper( + std::forward(element))) { + // T could be any non container or non tuple like type here, + // take int or std::future as an example. + return invoke_mapper(std::forward(element)); + } + + /// Forward the input to the deep remap methods in order + /// to prioritize the mapper before deep container remaps. + template + auto try_map(Category category, T&& element) + -> decltype(std::declval().try_deep_map( + category, std::forward(element))) { + return try_deep_map(category, std::forward(element)); + } + /// Traverses a single element. /// /// SFINAE helper: Doesn't allow routing through elements,