blob: 1fe39f7865398ef95e106bc3aa719c7512264198 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// 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 TEST_SUPPORT_MINIMAL_PRODUCT_HPP
#define TEST_SUPPORT_MINIMAL_PRODUCT_HPP
#include <boost/hana/fwd/core/make.hpp>
#include <boost/hana/fwd/first.hpp>
#include <boost/hana/fwd/second.hpp>
#include <type_traits>
struct MinimalProduct;
template <typename X, typename Y>
struct product_t {
X fst;
Y snd;
using hana_tag = MinimalProduct;
};
struct make_minimal_product {
template <typename T, typename U>
constexpr product_t<typename std::decay<T>::type,
typename std::decay<U>::type>
operator()(T&& t, U&& u) const {
return {static_cast<T&&>(t), static_cast<U&&>(u)};
}
};
constexpr make_minimal_product minimal_product{};
namespace boost { namespace hana {
//////////////////////////////////////////////////////////////////////////
// Product
//////////////////////////////////////////////////////////////////////////
template <>
struct make_impl<MinimalProduct> {
template <typename X, typename Y>
static constexpr auto apply(X x, Y y)
{ return ::minimal_product(x, y); }
};
template <>
struct first_impl<MinimalProduct> {
template <typename P>
static constexpr decltype(auto) apply(P&& p)
{ return p.fst; }
};
template <>
struct second_impl<MinimalProduct> {
template <typename P>
static constexpr decltype(auto) apply(P&& p)
{ return p.snd; }
};
}} // end namespace boost::hana
#endif // !TEST_SUPPORT_MINIMAL_PRODUCT_HPP
|