]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Defines `boost::hana::intersection`. | |
4 | ||
5 | @copyright Louis Dionne 2013-2016 | |
6 | Distributed under the Boost Software License, Version 1.0. | |
7 | (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
8 | */ | |
9 | ||
10 | #ifndef BOOST_HANA_INTERSECTION_HPP | |
11 | #define BOOST_HANA_INTERSECTION_HPP | |
12 | ||
13 | #include <boost/hana/fwd/intersection.hpp> | |
14 | ||
15 | #include <boost/hana/config.hpp> | |
16 | #include <boost/hana/core/dispatch.hpp> | |
17 | ||
18 | ||
19 | BOOST_HANA_NAMESPACE_BEGIN | |
20 | //! @cond | |
21 | template <typename Xs, typename Ys> | |
22 | constexpr auto intersection_t::operator()(Xs&& xs, Ys&& ys) const { | |
23 | using S = typename hana::tag_of<Xs>::type; | |
24 | using Intersection = BOOST_HANA_DISPATCH_IF(intersection_impl<S>, | |
25 | true | |
26 | ); | |
27 | ||
28 | return Intersection::apply(static_cast<Xs&&>(xs), static_cast<Ys&&>(ys)); | |
29 | } | |
30 | //! @endcond | |
31 | ||
32 | template <typename S, bool condition> | |
33 | struct intersection_impl<S, when<condition>> : default_ { | |
34 | template <typename ...Args> | |
35 | static constexpr auto apply(Args&& ...) = delete; | |
36 | }; | |
37 | BOOST_HANA_NAMESPACE_END | |
38 | ||
39 | #endif // !BOOST_HANA_INTERSECTION_HPP |