Files

46 lines
1.3 KiB
C++

/*!
@file
Defines `Boost::hana::second`.
@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 ACTIV_BOOST_HANA_SECOND_HPP
#define ACTIV_BOOST_HANA_SECOND_HPP
#include <ActivBoost/hana/fwd/second.hpp>
#include <ActivBoost/hana/concept/product.hpp>
#include <ActivBoost/hana/config.hpp>
#include <ActivBoost/hana/core/dispatch.hpp>
namespace Boost { namespace hana {
//! @cond
template <typename Pair>
constexpr decltype(auto) second_t::operator()(Pair&& pair) const {
using P = typename hana::tag_of<Pair>::type;
using Second = ACTIV_BOOST_HANA_DISPATCH_IF(second_impl<P>,
hana::Product<P>::value
);
#ifndef ACTIV_BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
static_assert(hana::Product<P>::value,
"hana::second(pair) requires 'pair' to be a Product");
#endif
return Second::apply(static_cast<Pair&&>(pair));
}
//! @endcond
template <typename P, bool condition>
struct second_impl<P, when<condition>> : default_ {
template <typename ...Args>
static constexpr auto apply(Args&& ...) = delete;
};
}} // end namespace Boost::hana
#endif // ACTIV_BOOST_!ACTIV_BOOST_HANA_SECOND_HPP