Edit: /usr/include/boost/hana/unique.hpp (2361B)
/*!
@file
Defines `boost::hana::unique`.
@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_UNIQUE_HPP
#define BOOST_HANA_UNIQUE_HPP
#include
#include
#include
#include
#include // required by fwd decl
#include
#include
#include
#include
BOOST_HANA_NAMESPACE_BEGIN
//! @cond
template
constexpr auto unique_t::operator()(Xs&& xs) const {
using S = typename hana::tag_of::type;
using Unique = BOOST_HANA_DISPATCH_IF(unique_impl,
hana::Sequence::value
);
#ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
static_assert(hana::Sequence::value,
"hana::unique(xs) requires 'xs' to be a Sequence");
#endif
return Unique::apply(static_cast(xs));
}
template
constexpr auto unique_t::operator()(Xs&& xs, Predicate&& predicate) const {
using S = typename hana::tag_of::type;
using Unique = BOOST_HANA_DISPATCH_IF(unique_impl,
hana::Sequence::value
);
#ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
static_assert(hana::Sequence::value,
"hana::unique(xs, predicate) requires 'xs' to be a Sequence");
#endif
return Unique::apply(static_cast(xs),
static_cast(predicate));
}
//! @endcond
template
struct unique_impl> : default_ {
template
static constexpr auto apply(Xs&& xs, Pred&& pred) {
return hana::transform(
hana::group(static_cast(xs), static_cast(pred)),
hana::front
);
}
template
static constexpr auto apply(Xs&& xs)
{ return unique_impl::apply(static_cast(xs), hana::equal); }
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_UNIQUE_HPP