1 //  Copyright (c) 2018-2019
2 //  Cem Bassoy
3 //
4 //  Distributed under the Boost Software License, Version 1.0. (See
5 //  accompanying file LICENSE_1_0.txt or copy at
6 //  http://www.boost.org/LICENSE_1_0.txt)
7 //
8 //  The authors gratefully acknowledge the support of
9 //  Fraunhofer and Google in producing this work
10 //  which started as a Google Summer of Code project.
11 //
12 
13 #ifndef _BOOST_UBLAS_TEST_TENSOR_UTILITY_
14 #define _BOOST_UBLAS_TEST_TENSOR_UTILITY_
15 
16 template<class ... types>
17 struct zip_helper;
18 
19 template<class type1, class ... types3>
20 struct zip_helper<std::tuple<types3...>, type1>
21 {
22 	template<class ... types2>
23 	struct with
24 	{
25 		using type = std::tuple<types3...,std::pair<type1,types2>...>;
26 	};
27 	template<class ... types2>
28 	using with_t = typename with<types2...>::type;
29 };
30 
31 
32 template<class type1, class ... types3, class ... types1>
33 struct zip_helper<std::tuple<types3...>, type1, types1...>
34 {
35 	template<class ... types2>
36 	struct with
37 	{
38 		using next_tuple = std::tuple<types3...,std::pair<type1,types2>...>;
39 		using type       = typename zip_helper<next_tuple, types1...>::template with<types2...>::type;
40 	};
41 
42 	template<class ... types2>
43 	using with_t = typename with<types2...>::type;
44 };
45 
46 template<class ... types>
47 using zip = zip_helper<std::tuple<>,types...>;
48 
49 // creates e.g.
50 // using test_types = zip<long,float>::with_t<first_order,last_order>; // equals
51 // using test_types = std::tuple< std::pair<float, first_order>, std::pair<float, last_order >, std::pair<double,first_order>, std::pair<double,last_order >
52 //>;
53 //static_assert(std::is_same< std::tuple_element_t<0,std::tuple_element_t<0,test_types2>>, float>::value,"should be float ");
54 //static_assert(std::is_same< std::tuple_element_t<1,std::tuple_element_t<0,test_types2>>, boost::numeric::ublas::first_order>::value,"should be boost::numeric::ublas::first_order ");
55 
56 #endif
57