utility.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #ifndef _BOOST_UBLAS_TEST_TENSOR_UTILITY_
  13. #define _BOOST_UBLAS_TEST_TENSOR_UTILITY_
  14. template<class ... types>
  15. struct zip_helper;
  16. template<class type1, class ... types3>
  17. struct zip_helper<std::tuple<types3...>, type1>
  18. {
  19. template<class ... types2>
  20. struct with
  21. {
  22. using type = std::tuple<types3...,std::pair<type1,types2>...>;
  23. };
  24. template<class ... types2>
  25. using with_t = typename with<types2...>::type;
  26. };
  27. template<class type1, class ... types3, class ... types1>
  28. struct zip_helper<std::tuple<types3...>, type1, types1...>
  29. {
  30. template<class ... types2>
  31. struct with
  32. {
  33. using next_tuple = std::tuple<types3...,std::pair<type1,types2>...>;
  34. using type = typename zip_helper<next_tuple, types1...>::template with<types2...>::type;
  35. };
  36. template<class ... types2>
  37. using with_t = typename with<types2...>::type;
  38. };
  39. template<class ... types>
  40. using zip = zip_helper<std::tuple<>,types...>;
  41. // creates e.g.
  42. // using test_types = zip<long,float>::with_t<first_order,last_order>; // equals
  43. // 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 >
  44. //>;
  45. //static_assert(std::is_same< std::tuple_element_t<0,std::tuple_element_t<0,test_types2>>, float>::value,"should be float ");
  46. //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 ");
  47. #endif