/// \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 namespace ranges { /// \cond namespace adl_push_front_detail { 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 auto push_front(Cont && cont, T && t) -> CPP_ret(push_front_t)( // requires lvalue_container_like && (!range)&&constructible_from, T>) { unwrap_reference(cont).push_front(static_cast(t)); } template auto push_front(Cont && cont, Rng && rng) -> CPP_ret(insert_t)( // requires lvalue_container_like && range) { ranges::insert(cont, begin(cont), static_cast(rng)); } // clang-format off CPP_def ( template(typename Rng, typename T) concept can_push_front_, requires (Rng &&rng, T &&t) ( push_front(rng, (T &&) t) ) ); // clang-format on struct push_front_fn { private: friend actions::action_access; template static auto bind(push_front_fn push_front, T && val) { return bind_back(push_front, static_cast(val)); } #ifdef RANGES_WORKAROUND_MSVC_OLD_LAMBDA template struct lamduh { T (&val_)[N]; template auto operator()(Rng && rng) const -> invoke_result_t { return push_front_fn{}(static_cast(rng), val_); } }; template static lamduh bind(push_front_fn, T (&val)[N]) { return {val}; } #else // ^^^ workaround / no workaround vvv template static auto bind(push_front_fn, T (&val)[N]) { return [&val](auto && rng) -> invoke_result_t { return push_front_fn{}(static_cast(rng), val); }; } #endif // RANGES_WORKAROUND_MSVC_OLD_LAMBDA public: template auto operator()(Rng && rng, T && t) const -> CPP_ret(Rng)( // requires input_range && can_push_front_ && (range || constructible_from, T>)) { push_front(rng, static_cast(t)); return static_cast(rng); } }; } // namespace adl_push_front_detail /// \endcond namespace actions { /// \ingroup group-actions RANGES_INLINE_VARIABLE( detail::with_braced_init_args>, push_front) } // namespace actions using actions::push_front; } // namespace ranges #endif