Created
June 30, 2014 12:29
-
-
Save kotoji/0670e0f0afaf16545541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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