/*! @file Defines `boost::hana::fill`. @copyright Louis Dionne 2013-2016 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FILL_HPP #define BOOST_HANA_FILL_HPP #include #include #include #include #include #include #include #include #include BOOST_HANA_NAMESPACE_BEGIN //! @cond template constexpr auto fill_t::operator()(Xs&& xs, Value&& value) const { using S = typename hana::tag_of::type; using Fill = BOOST_HANA_DISPATCH_IF(fill_impl, hana::Functor::value ); #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Functor::value, "hana::fill(xs, value) requires 'xs' to be a Functor"); #endif return Fill::apply(static_cast(xs), static_cast(value)); } //! @endcond template struct fill_impl> : default_ { template static constexpr auto apply(Xs&& xs, Value&& v) { return hana::transform(static_cast(xs), hana::always(static_cast(v)) ); } }; template struct fill_impl::value>> { //! @cond template struct filler { V const& v; template constexpr auto operator()(Xs const& ...xs) const { return hana::make(((void)xs, v)...); } }; //! @endcond template static constexpr auto apply(Xs const& xs, V const& v) { return hana::unpack(xs, filler{v}); } }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FILL_HPP