1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/tpp/algorithm/all_of.hpp

55 lines
1.7 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
2014-01-08 07:48:12 +00:00
Copyright (c) 2011-2014 Bolero MURAKAMI
2013-08-08 09:54:33 +00:00
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
2012-10-04 14:25:28 +00:00
#ifndef SPROUT_TPP_ALGORITHM_ALL_OF_HPP
#define SPROUT_TPP_ALGORITHM_ALL_OF_HPP
#include <type_traits>
#include <sprout/config.hpp>
2014-09-20 03:55:29 +00:00
#include <sprout/workaround/std/cstddef.hpp>
#include <sprout/type_traits/integral_constant.hpp>
2014-09-20 03:55:29 +00:00
#include <sprout/type/type_tuple.hpp>
2012-10-04 14:25:28 +00:00
namespace sprout {
namespace tpp {
namespace detail {
2014-09-20 03:55:29 +00:00
template<typename Tup, std::size_t First, std::size_t Last, bool = (Last - First == 1)>
struct all_of_impl
: public std::tuple_element<First, Tup>::type
2012-11-02 13:00:10 +00:00
{};
2014-09-20 03:55:29 +00:00
template<typename Tup, std::size_t First, std::size_t Last>
struct all_of_impl<Tup, First, Last, false>
: public sprout::integral_constant<
bool,
sprout::tpp::detail::all_of_impl<Tup, First, (First + Last) / 2>::value
&& sprout::tpp::detail::all_of_impl<Tup, (First + Last) / 2, Last>::value
>
2012-10-04 14:25:28 +00:00
{};
} // namespace detail
//
2012-11-02 13:00:10 +00:00
// all_of
//
template<typename... Types>
struct all_of
2014-09-20 03:55:29 +00:00
: public sprout::tpp::detail::all_of_impl<sprout::types::type_tuple<Types...>, 0, sizeof...(Types)>
{};
template<>
struct all_of<>
: public sprout::true_type
{};
//
// all_of_c
//
template<bool... Values>
struct all_of_c
: public sprout::tpp::all_of<sprout::integral_constant<bool, Values>...>
2012-11-02 13:00:10 +00:00
{};
2012-10-04 14:25:28 +00:00
} // namespace tpp
} // namespace sprout
#endif // #ifndef SPROUT_TPP_ALGORITHM_ALL_OF_HPP