/// \file // Range v3 library // // Copyright Eric Niebler 2013-present // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // Project home: https://github.com/ericniebler/range-v3 // #ifndef RANGES_V3_ACTION_PUSH_FRONT_HPP #define RANGES_V3_ACTION_PUSH_FRONT_HPP #include #include #include #include #include #include #include #include #include namespace ranges { /// \addtogroup group-actions /// @{ /// \cond namespace adl_push_front_detail { /// \endcond template using push_front_t = decltype(static_cast( unwrap_reference(std::declval()).push_front(std::declval()))); template using insert_t = decltype(static_cast( ranges::insert(std::declval(), std::declval>(), std::declval()))); template(typename Cont, typename T)( requires lvalue_container_like AND (!range) AND constructible_from, T>) push_front_t push_front(Cont && cont, T && t) { unwrap_reference(cont).push_front(static_cast(t)); } template(typename Cont, typename Rng)( requires lvalue_container_like AND range) insert_t push_front(Cont && cont, Rng && rng) { ranges::insert(cont, begin(cont), static_cast(rng)); } /// \cond // clang-format off /// \concept can_push_front_frag_ /// \brief The \c can_push_front_frag_ concept template CPP_requires(can_push_front_frag_, requires(Rng && rng, T && t) // ( push_front(rng, (T &&) t) )); /// \concept can_push_front_ /// \brief The \c can_push_front_ concept template CPP_concept can_push_front_ = CPP_requires_ref(adl_push_front_detail::can_push_front_frag_, Rng, T); // clang-format on /// \endcond struct push_front_fn { template constexpr auto operator()(T && val) const { return make_action_closure( bind_back(push_front_fn{}, static_cast(val))); } template constexpr auto operator()(std::initializer_list val) const { return make_action_closure(bind_back(push_front_fn{}, val)); } template(typename T)( requires range) constexpr auto operator()(T & t) const { return make_action_closure( bind_back(push_front_fn{}, detail::reference_wrapper_(t))); } template(typename Rng, typename T)( requires input_range AND can_push_front_ AND (range || constructible_from, T>)) // Rng operator()(Rng && rng, T && t) const // { push_front(rng, static_cast(t)); return static_cast(rng); } template(typename Rng, typename T)( requires input_range AND can_push_front_> AND constructible_from, T const &>) Rng operator()(Rng && rng, std::initializer_list t) const // { push_front(rng, t); return static_cast(rng); } /// \cond template invoke_result_t // operator()(Rng && rng, detail::reference_wrapper_ r) const { return (*this)(static_cast(rng), r.get()); } /// \endcond }; /// \cond } // namespace adl_push_front_detail /// \endcond namespace actions { RANGES_INLINE_VARIABLE(adl_push_front_detail::push_front_fn, push_front) } // namespace actions using actions::push_front; /// @} } // namespace ranges #include #endif