From ac80a049708a246211a200c493c6db5bf0eb63d1 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Fri, 2 Nov 2012 22:00:10 +0900 Subject: [PATCH] add tpp one_of --- sprout/tpp/algorithm.hpp | 1 + sprout/tpp/algorithm/all_of.hpp | 17 +++++++++-- sprout/tpp/algorithm/any_of.hpp | 17 +++++++++-- sprout/tpp/algorithm/none_of.hpp | 17 +++++++++-- sprout/tpp/algorithm/one_of.hpp | 51 ++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 sprout/tpp/algorithm/one_of.hpp diff --git a/sprout/tpp/algorithm.hpp b/sprout/tpp/algorithm.hpp index 7ec63b78..e91648e4 100644 --- a/sprout/tpp/algorithm.hpp +++ b/sprout/tpp/algorithm.hpp @@ -5,5 +5,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_TPP_ALGORITHM_HPP diff --git a/sprout/tpp/algorithm/all_of.hpp b/sprout/tpp/algorithm/all_of.hpp index 79a9d258..3640cd7f 100644 --- a/sprout/tpp/algorithm/all_of.hpp +++ b/sprout/tpp/algorithm/all_of.hpp @@ -7,9 +7,13 @@ namespace sprout { namespace tpp { namespace detail { - template + template struct all_of_impl; template<> + struct all_of_impl<> + : public std::true_type + {}; + template<> struct all_of_impl : public std::true_type {}; @@ -27,12 +31,19 @@ namespace sprout { {}; } // namespace detail // - // all_of + // all_of_c // template - struct all_of + struct all_of_c : public sprout::tpp::detail::all_of_impl {}; + // + // all_of + // + template + struct all_of + : public sprout::tpp::all_of_c + {}; } // namespace tpp } // namespace sprout diff --git a/sprout/tpp/algorithm/any_of.hpp b/sprout/tpp/algorithm/any_of.hpp index 2ededd43..b71e8b5c 100644 --- a/sprout/tpp/algorithm/any_of.hpp +++ b/sprout/tpp/algorithm/any_of.hpp @@ -7,9 +7,13 @@ namespace sprout { namespace tpp { namespace detail { - template + template struct any_of_impl; template<> + struct any_of_impl<> + : public std::false_type + {}; + template<> struct any_of_impl : public std::true_type {}; @@ -27,12 +31,19 @@ namespace sprout { {}; } // namespace detail // - // any_of + // any_of_c // template - struct any_of + struct any_of_c : public sprout::tpp::detail::any_of_impl {}; + // + // any_of + // + template + struct any_of + : public sprout::tpp::any_of_c + {}; } // namespace tpp } // namespace sprout diff --git a/sprout/tpp/algorithm/none_of.hpp b/sprout/tpp/algorithm/none_of.hpp index bcf63bcd..bec0ad0e 100644 --- a/sprout/tpp/algorithm/none_of.hpp +++ b/sprout/tpp/algorithm/none_of.hpp @@ -7,9 +7,13 @@ namespace sprout { namespace tpp { namespace detail { - template + template struct none_of_impl; template<> + struct none_of_impl<> + : public std::true_type + {}; + template<> struct none_of_impl : public std::false_type {}; @@ -27,12 +31,19 @@ namespace sprout { {}; } // namespace detail // - // none_of + // none_of_c // template - struct none_of + struct none_of_c : public sprout::tpp::detail::none_of_impl {}; + // + // none_of + // + template + struct none_of + : public sprout::tpp::none_of_c + {}; } // namespace tpp } // namespace sprout diff --git a/sprout/tpp/algorithm/one_of.hpp b/sprout/tpp/algorithm/one_of.hpp new file mode 100644 index 00000000..3f6e6168 --- /dev/null +++ b/sprout/tpp/algorithm/one_of.hpp @@ -0,0 +1,51 @@ +#ifndef SPROUT_TPP_ALGORITHM_ONE_OF_HPP +#define SPROUT_TPP_ALGORITHM_ONE_OF_HPP + +#include +#include +#include + +namespace sprout { + namespace tpp { + namespace detail { + template + struct one_of_impl; + template<> + struct one_of_impl<> + : public std::false_type + {}; + template<> + struct one_of_impl + : public std::true_type + {}; + template<> + struct one_of_impl + : public std::false_type + {}; + template + struct one_of_impl + : public sprout::tpp::none_of_c + {}; + template + struct one_of_impl + : public std::integral_constant::value> + {}; + } // namespace detail + // + // one_of_c + // + template + struct one_of_c + : public sprout::tpp::detail::one_of_impl + {}; + // + // one_of + // + template + struct one_of + : public sprout::tpp::one_of_c + {}; + } // namespace tpp +} // namespace sprout + +#endif // #ifndef SPROUT_TPP_ALGORITHM_ONE_OF_HPP