Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-25 10:02:37

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 /// @file
0009 /// Defines helper routines and types for merging monomorphic samples
0010 // ***************************************************************************
0011 
0012 #ifndef BOOST_TEST_DATA_MONOMORPHIC_SAMPLE_MERGE_HPP
0013 #define BOOST_TEST_DATA_MONOMORPHIC_SAMPLE_MERGE_HPP
0014 
0015 // Boost.Test
0016 #include <boost/test/data/config.hpp>
0017 #include <boost/test/data/index_sequence.hpp>
0018 
0019 #include <boost/test/data/monomorphic/fwd.hpp>
0020 
0021 #include <boost/test/detail/suppress_warnings.hpp>
0022 
0023 namespace boost {
0024 namespace unit_test {
0025 namespace data {
0026 namespace monomorphic {
0027 
0028 //____________________________________________________________________________//
0029 
0030 namespace ds_detail {
0031 
0032 template <class T>
0033 struct is_tuple : std::false_type {};
0034 
0035 template <class ...T>
0036 struct is_tuple<std::tuple<T...>> : std::true_type {};
0037 
0038 template <class T>
0039 struct is_tuple<T&&> : is_tuple<typename std::decay<T>::type> {};
0040 
0041 template <class T>
0042 struct is_tuple<T&> : is_tuple<typename std::decay<T>::type> {};
0043 
0044 template<typename T>
0045 inline auto as_tuple_impl_xvalues( T const & arg, std::false_type  /* is_rvalue_ref */ )
0046   -> decltype(std::tuple<T const&>(arg)) {
0047     //return std::tuple<T const&>(arg);
0048     return std::forward_as_tuple(arg);
0049 }
0050 
0051 template<typename T>
0052 inline auto as_tuple_impl_xvalues( T && arg, std::true_type  /* is_rvalue_ref */ )
0053   -> decltype(std::make_tuple(std::forward<T>(arg))) {
0054     return std::make_tuple(std::forward<T>(arg));
0055 }
0056 
0057 
0058 template<typename T>
0059 inline auto as_tuple_impl( T && arg, std::false_type  /* is_tuple = nullptr */ )
0060   -> decltype(as_tuple_impl_xvalues(std::forward<T>(arg),
0061               typename std::is_rvalue_reference<T&&>::type())) {
0062     return as_tuple_impl_xvalues(std::forward<T>(arg),
0063                                  typename std::is_rvalue_reference<T&&>::type());
0064 }
0065 
0066 //____________________________________________________________________________//
0067 
0068 template<typename T>
0069 inline T &&
0070 as_tuple_impl(T && arg, std::true_type  /* is_tuple */ ) {
0071     return std::forward<T>(arg);
0072 }
0073 
0074 template<typename T>
0075 inline auto as_tuple( T && arg )
0076   -> decltype( as_tuple_impl(std::forward<T>(arg),
0077                              typename ds_detail::is_tuple<T>::type()) ) {
0078   return as_tuple_impl(std::forward<T>(arg),
0079                        typename ds_detail::is_tuple<T>::type());
0080 }
0081 
0082 //____________________________________________________________________________//
0083 
0084 } // namespace ds_detail
0085 
0086 template<typename T1, typename T2>
0087 inline auto
0088 sample_merge( T1 && a1, T2 && a2 )
0089     -> decltype( std::tuple_cat(ds_detail::as_tuple(std::forward<T1>(a1)),
0090                                 ds_detail::as_tuple(std::forward<T2>(a2)) ) ) {
0091     return std::tuple_cat(ds_detail::as_tuple(std::forward<T1>(a1)),
0092                           ds_detail::as_tuple(std::forward<T2>(a2)));
0093 }
0094 
0095 } // namespace monomorphic
0096 } // namespace data
0097 } // namespace unit_test
0098 } // namespace boost
0099 
0100 #include <boost/test/detail/enable_warnings.hpp>
0101 
0102 #endif // BOOST_TEST_DATA_MONOMORPHIC_SAMPLE_MERGE_HPP
0103