Skip to content

Instantly share code, notes, and snippets.

@kotoji
Created June 30, 2014 12:29
Show Gist options
  • Save kotoji/0670e0f0afaf16545541 to your computer and use it in GitHub Desktop.
Save kotoji/0670e0f0afaf16545541 to your computer and use it in GitHub Desktop.
#include <boost/mpl/and.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/placeholders.hpp>
#include <type_traits>
#include <iostream>
namespace mpl = boost::mpl;
template <typename Cond, typename Seq, std::size_t I>
struct any_impl {
static constexpr bool value = mpl::apply<Cond, typename std::tuple_element<I, Seq>::type>::type::value
&& any_impl<Cond, Seq, I - 1>::value;
};
template <typename Cond, typename Seq>
struct any_impl<Cond, Seq, 0> {
static constexpr bool value = mpl::apply<Cond, typename std::tuple_element<0, Seq>::type>::type::value;
};
template <typename Cond, typename... Types>
struct any_ : any_impl<Cond, std::tuple<Types...> , sizeof...(Types) - 1> {};
int main() {
std::cout << any_<std::is_integral<mpl::_1>, int, int, double>::value << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment