Edit: /usr/include/boost/hana/replicate.hpp (2282B)
/*!
@file
Defines `boost::hana::replicate`.
@copyright Louis Dionne 2013-2017
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_REPLICATE_HPP
#define BOOST_HANA_REPLICATE_HPP
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
BOOST_HANA_NAMESPACE_BEGIN
//! @cond
template
template
constexpr auto replicate_t::operator()(X&& x, N const& n) const {
using Replicate = BOOST_HANA_DISPATCH_IF(replicate_impl,
hana::MonadPlus::value &&
hana::IntegralConstant::value
);
#ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
static_assert(hana::MonadPlus::value,
"hana::replicate(x, n) requires 'M' to be a MonadPlus");
static_assert(hana::IntegralConstant::value,
"hana::replicate(x, n) requires 'n' to be an IntegralConstant");
#endif
return Replicate::apply(static_cast(x), n);
}
//! @endcond
template
struct replicate_impl> : default_ {
template
static constexpr auto apply(X&& x, N const& n) {
return hana::cycle(hana::lift(static_cast(x)), n);
}
};
template
struct replicate_impl::value>> {
template
static constexpr auto replicate_helper(X&& x, std::index_sequence)
{ return hana::make(((void)i, x)...); }
template
static constexpr auto apply(X&& x, N const&) {
constexpr std::size_t n = N::value;
return replicate_helper(static_cast(x),
std::make_index_sequence{});
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_REPLICATE_HPP