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)
6 // See http://www.boost.org/libs/test for the library home page.
9 /// Defines helper routines and types for merging monomorphic samples
10 // ***************************************************************************
12 #ifndef BOOST_TEST_DATA_MONOMORPHIC_SAMPLE_MERGE_HPP
13 #define BOOST_TEST_DATA_MONOMORPHIC_SAMPLE_MERGE_HPP
16 #include <boost/test/data/config.hpp>
17 #include <boost/test/data/index_sequence.hpp>
19 #include <boost/test/data/monomorphic/fwd.hpp>
21 #include <boost/test/detail/suppress_warnings.hpp>
26 namespace monomorphic {
28 //____________________________________________________________________________//
33 struct is_tuple : std::false_type {};
36 struct is_tuple<std::tuple<T...>> : std::true_type {};
39 struct is_tuple<T&&> : is_tuple<typename std::decay<T>::type> {};
42 struct is_tuple<T&> : is_tuple<typename std::decay<T>::type> {};
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);
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));
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());
66 //____________________________________________________________________________//
70 as_tuple_impl(T && arg, std::true_type /* is_tuple */ ) {
71 return std::forward<T>(arg);
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());
82 //____________________________________________________________________________//
84 } // namespace ds_detail
86 template<typename T1, typename T2>
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)));
95 } // namespace monomorphic
97 } // namespace unit_test
100 #include <boost/test/detail/enable_warnings.hpp>
102 #endif // BOOST_TEST_DATA_MONOMORPHIC_SAMPLE_MERGE_HPP