• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
5 #ifndef BOOST_HANA_TEST_AUTO_IS_EMPTY_HPP
6 #define BOOST_HANA_TEST_AUTO_IS_EMPTY_HPP
7 
8 #include <boost/hana/assert.hpp>
9 #include <boost/hana/is_empty.hpp>
10 #include <boost/hana/not.hpp>
11 
12 #include "test_case.hpp"
13 
14 
15 namespace _test_is_empty_detail { template <int i> struct undefined { }; }
16 
__anon22e405a10102null17 TestCase test_is_empty{[]{
18     namespace hana = boost::hana;
19     using _test_is_empty_detail::undefined;
20 
21     BOOST_HANA_CONSTANT_CHECK(hana::is_empty(
22         MAKE_TUPLE()
23     ));
24 
25     BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(
26         MAKE_TUPLE(undefined<0>{})
27     )));
28 
29     BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(
30         MAKE_TUPLE(undefined<0>{}, undefined<1>{})
31     )));
32 
33     BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(
34         MAKE_TUPLE(undefined<0>{}, undefined<1>{}, undefined<2>{})
35     )));
36 
37     BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(
38         MAKE_TUPLE(undefined<0>{}, undefined<1>{}, undefined<2>{}, undefined<3>{})
39     )));
40 
41     // Check with a runtime value
42     {
43         int i = 3; // <- runtime value
44         BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(MAKE_TUPLE(i))));
45         BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(MAKE_TUPLE(i, i))));
46     }
47 
48 #ifndef MAKE_TUPLE_NO_CONSTEXPR
49     static_assert(hana::is_empty(MAKE_TUPLE()), "");
50     static_assert(hana::not_(hana::is_empty(MAKE_TUPLE(undefined<0>{}))), "");
51     static_assert(hana::not_(hana::is_empty(MAKE_TUPLE(undefined<0>{}, undefined<1>{}))), "");
52 #endif
53 }};
54 
55 #endif // !BOOST_HANA_TEST_AUTO_IS_EMPTY_HPP
56