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/none_of.hpp

54 lines
1.8 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
2015-01-10 10:13:57 +00:00
Copyright (c) 2011-2015 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_NONE_OF_HPP
#define SPROUT_TPP_ALGORITHM_NONE_OF_HPP
2014-09-20 03:55:29 +00:00
#include <type_traits>
2012-10-04 14:25:28 +00:00
#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 none_of_impl
2014-12-10 10:54:12 +00:00
: public sprout::bool_constant<!std::tuple_element<First, Tup>::type::value>
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 none_of_impl<Tup, First, Last, false>
2014-12-10 10:54:12 +00:00
: public sprout::bool_constant<
2014-09-20 03:55:29 +00:00
sprout::tpp::detail::none_of_impl<Tup, First, (First + Last) / 2>::value
&& sprout::tpp::detail::none_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
// none_of
//
template<typename... Types>
struct none_of
2014-09-20 03:55:29 +00:00
: public sprout::tpp::detail::none_of_impl<sprout::types::type_tuple<Types...>, 0, sizeof...(Types)>
{};
template<>
struct none_of<>
: public sprout::true_type
{};
//
// none_of_c
//
template<bool... Values>
struct none_of_c
2014-12-10 10:54:12 +00:00
: public sprout::tpp::none_of<sprout::bool_constant<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_NONE_OF_HPP