is_empty.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/experimental/view.hpp>
  6. #include <boost/hana/is_empty.hpp>
  7. #include <boost/hana/not.hpp>
  8. #include <boost/hana/tuple.hpp>
  9. #include <support/seq.hpp>
  10. namespace hana = boost::hana;
  11. template <int> struct undefined { };
  12. int main() {
  13. auto container = ::seq;
  14. {
  15. auto storage = container();
  16. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>);
  17. BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced));
  18. }{
  19. auto storage = container(undefined<0>{});
  20. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>);
  21. BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced));
  22. }{
  23. auto storage = container(undefined<0>{}, undefined<1>{});
  24. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>);
  25. BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced));
  26. }
  27. {
  28. auto storage = container(undefined<0>{});
  29. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>);
  30. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(sliced)));
  31. }{
  32. auto storage = container(undefined<0>{});
  33. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 0>);
  34. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(sliced)));
  35. }
  36. {
  37. auto storage = container(undefined<0>{}, undefined<1>{});
  38. auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 1>);
  39. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(sliced)));
  40. }
  41. }