1 // Copyright Louis Dionne 2013-2017
2 // Copyright Jason Rice 2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
6 #ifndef TEST_SUPPORT_COUNTER_HPP
7 #define TEST_SUPPORT_COUNTER_HPP
9 #include <boost/hana/fwd/at.hpp>
10 #include <boost/hana/fwd/concept/iterable.hpp>
11 #include <boost/hana/fwd/drop_front.hpp>
12 #include <boost/hana/fwd/is_empty.hpp>
13 #include <boost/hana/integral_constant.hpp>
16 // Counter - an infinite iterable for the masses
18 struct Counter_tag { };
20 template <std::size_t N = 0>
22 using hana_tag = Counter_tag;
23 static constexpr std::size_t value = N;
27 namespace boost { namespace hana {
28 //////////////////////////////////////////////////////////////////////////
30 //////////////////////////////////////////////////////////////////////////
32 struct at_impl<Counter_tag> {
33 template <typename T, typename N>
34 static constexpr decltype(auto) apply(T, N) {
35 return hana::size_c<T::value + N::value>;
40 struct drop_front_impl<Counter_tag> {
41 template <typename T, typename N>
42 static constexpr auto apply(T, N) {
43 return Counter<T::value + N::value>{};
48 struct is_empty_impl<Counter_tag> {
49 template <typename Xs>
50 static constexpr auto apply(Xs)
54 }} // end namespace boost::hana
56 #endif // !TEST_SUPPORT_COUNTER_HPP