]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/test/data/monomorphic/sample_merge.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / test / data / monomorphic / sample_merge.hpp
1 // (C) Copyright Gennadiy Rozental 2001.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6 // See http://www.boost.org/libs/test for the library home page.
7 //
8 /// @file
9 /// Defines helper routines and types for merging monomorphic samples
10 // ***************************************************************************
11
12 #ifndef BOOST_TEST_DATA_MONOMORPHIC_SAMPLE_MERGE_HPP
13 #define BOOST_TEST_DATA_MONOMORPHIC_SAMPLE_MERGE_HPP
14
15 // Boost.Test
16 #include <boost/test/data/config.hpp>
17 #include <boost/test/data/index_sequence.hpp>
18
19 #include <boost/test/data/monomorphic/fwd.hpp>
20
21 #include <boost/test/detail/suppress_warnings.hpp>
22
23 namespace boost {
24 namespace unit_test {
25 namespace data {
26 namespace monomorphic {
27
28 //____________________________________________________________________________//
29
30 namespace ds_detail {
31
32 template <class T>
33 struct is_tuple : std::false_type {};
34
35 template <class ...T>
36 struct is_tuple<std::tuple<T...>> : std::true_type {};
37
38 template <class T>
39 struct is_tuple<T&&> : is_tuple<typename std::decay<T>::type> {};
40
41 template <class T>
42 struct is_tuple<T&> : is_tuple<typename std::decay<T>::type> {};
43
44 template<typename T>
45 inline auto as_tuple_impl_xvalues( T const & arg, std::false_type /* is_rvalue_ref */ )
46 -> decltype(std::tuple<T const&>(arg)) {
47 //return std::tuple<T const&>(arg);
48 return std::forward_as_tuple(arg);
49 }
50
51 template<typename T>
52 inline auto as_tuple_impl_xvalues( T && arg, std::true_type /* is_rvalue_ref */ )
53 -> decltype(std::make_tuple(std::forward<T>(arg))) {
54 return std::make_tuple(std::forward<T>(arg));
55 }
56
57
58 template<typename T>
59 inline auto as_tuple_impl( T && arg, std::false_type /* is_tuple = nullptr */ )
60 -> decltype(as_tuple_impl_xvalues(std::forward<T>(arg),
61 typename std::is_rvalue_reference<T&&>::type())) {
62 return as_tuple_impl_xvalues(std::forward<T>(arg),
63 typename std::is_rvalue_reference<T&&>::type());
64 }
65
66 //____________________________________________________________________________//
67
68 template<typename T>
69 inline T &&
70 as_tuple_impl(T && arg, std::true_type /* is_tuple */ ) {
71 return std::forward<T>(arg);
72 }
73
74 template<typename T>
75 inline auto as_tuple( T && arg )
76 -> decltype( as_tuple_impl(std::forward<T>(arg),
77 typename ds_detail::is_tuple<T>::type()) ) {
78 return as_tuple_impl(std::forward<T>(arg),
79 typename ds_detail::is_tuple<T>::type());
80 }
81
82 //____________________________________________________________________________//
83
84 } // namespace ds_detail
85
86 template<typename T1, typename T2>
87 inline auto
88 sample_merge( T1 && a1, T2 && a2 )
89 -> decltype( std::tuple_cat(ds_detail::as_tuple(std::forward<T1>(a1)),
90 ds_detail::as_tuple(std::forward<T2>(a2)) ) ) {
91 return std::tuple_cat(ds_detail::as_tuple(std::forward<T1>(a1)),
92 ds_detail::as_tuple(std::forward<T2>(a2)));
93 }
94
95 } // namespace monomorphic
96 } // namespace data
97 } // namespace unit_test
98 } // namespace boost
99
100 #include <boost/test/detail/enable_warnings.hpp>
101
102 #endif // BOOST_TEST_DATA_MONOMORPHIC_SAMPLE_MERGE_HPP
103