mirror of
https://github.com/boostorg/hana.git
synced 2026-01-28 07:12:15 +00:00
- Split type class instances into separate files - Instances provided automatically by a type class are actually MCDs - Test each instance in a single file, not one file per method - Refactor the operator system to fix the ADL-related bug.
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
/*
|
|
@copyright Louis Dionne 2014
|
|
Distributed under the Boost Software License, Version 1.0.
|
|
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
|
|
*/
|
|
|
|
#include <boost/hana/ext/std/array.hpp>
|
|
|
|
#include <boost/hana/detail/assert.hpp>
|
|
#include <boost/hana/foreign.hpp>
|
|
|
|
#include <array>
|
|
#include <test/laws/iterable.hpp>
|
|
using namespace boost::hana;
|
|
|
|
|
|
template <int ...i>
|
|
constexpr auto array = std::array<int, sizeof...(i)>{{i...}};
|
|
|
|
int main() {
|
|
// is_empty
|
|
{
|
|
BOOST_HANA_CONSTANT_ASSERT(is_empty(array<>));
|
|
BOOST_HANA_CONSTANT_ASSERT(not_(is_empty(array<0>)));
|
|
BOOST_HANA_CONSTANT_ASSERT(not_(is_empty(array<0, 1>)));
|
|
}
|
|
|
|
// head
|
|
{
|
|
BOOST_HANA_CONSTEXPR_ASSERT(head(array<0>) == 0);
|
|
BOOST_HANA_CONSTEXPR_ASSERT(head(array<0, 1>) == 0);
|
|
BOOST_HANA_CONSTEXPR_ASSERT(head(array<0, 1, 2>) == 0);
|
|
}
|
|
|
|
// tail
|
|
{
|
|
BOOST_HANA_CONSTANT_ASSERT(equal(tail(array<0>), array<>));
|
|
BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(array<0, 1>), array<1>));
|
|
BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(array<0, 1, 2>), array<1, 2>));
|
|
BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(array<0, 1, 2, 3>), array<1, 2, 3>));
|
|
}
|
|
|
|
// laws
|
|
{
|
|
BOOST_HANA_CONSTEXPR_ASSERT(Iterable_laws(
|
|
array<>,
|
|
array<0>,
|
|
array<0, 1>,
|
|
array<0, 1, 2>
|
|
));
|
|
}
|
|
}
|