at.cpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Copyright Louis Dionne 2013-2017
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  4. #include <boost/hana/assert.hpp>
  5. #include <boost/hana/at.hpp>
  6. #include <boost/hana/equal.hpp>
  7. #include <boost/hana/experimental/view.hpp>
  8. #include <boost/hana/integral_constant.hpp>
  9. #include <boost/hana/tuple.hpp>
  10. #include <laws/base.hpp>
  11. #include <support/seq.hpp>
  12. namespace hana = boost::hana;
  13. using hana::test::ct_eq;
  14. int main() {
  15. auto container = ::seq;
  16. {
  17. auto storage = container(ct_eq<0>{});
  18. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>);
  19. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  20. hana::at(sliced, hana::size_c<0>),
  21. ct_eq<0>{}
  22. ));
  23. }
  24. {
  25. auto storage = container(ct_eq<0>{}, ct_eq<1>{});
  26. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>);
  27. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  28. hana::at(sliced, hana::size_c<0>),
  29. ct_eq<0>{}
  30. ));
  31. }{
  32. auto storage = container(ct_eq<0>{}, ct_eq<1>{});
  33. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1>);
  34. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  35. hana::at(sliced, hana::size_c<0>),
  36. ct_eq<1>{}
  37. ));
  38. }{
  39. auto storage = container(ct_eq<0>{}, ct_eq<1>{});
  40. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 1>);
  41. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  42. hana::at(sliced, hana::size_c<0>),
  43. ct_eq<0>{}
  44. ));
  45. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  46. hana::at(sliced, hana::size_c<1>),
  47. ct_eq<1>{}
  48. ));
  49. }{
  50. auto storage = container(ct_eq<0>{}, ct_eq<1>{});
  51. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1, 0>);
  52. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  53. hana::at(sliced, hana::size_c<0>),
  54. ct_eq<1>{}
  55. ));
  56. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  57. hana::at(sliced, hana::size_c<1>),
  58. ct_eq<0>{}
  59. ));
  60. }{
  61. auto storage = container(ct_eq<0>{}, ct_eq<1>{});
  62. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 0>);
  63. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  64. hana::at(sliced, hana::size_c<0>),
  65. ct_eq<0>{}
  66. ));
  67. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  68. hana::at(sliced, hana::size_c<1>),
  69. ct_eq<0>{}
  70. ));
  71. }
  72. {
  73. auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{});
  74. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1, 3>);
  75. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  76. hana::at(sliced, hana::size_c<0>),
  77. ct_eq<1>{}
  78. ));
  79. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  80. hana::at(sliced, hana::size_c<1>),
  81. ct_eq<3>{}
  82. ));
  83. }
  84. }