2016-03-04 11:20:56 +00:00
|
|
|
|
2016-03-15 10:29:13 +00:00
|
|
|
// This work derives from Vittorio Romeo's code used for cppcon 2015 licensed under the Academic Free License.
|
|
|
|
// His code is available here: https://github.com/SuperV1234/cppcon2015
|
|
|
|
|
|
|
|
|
2016-03-04 11:20:56 +00:00
|
|
|
#ifndef EC_META_CONTAINS_HPP
|
|
|
|
#define EC_META_CONTAINS_HPP
|
|
|
|
|
2016-03-04 12:12:37 +00:00
|
|
|
#include <type_traits>
|
2016-03-04 11:20:56 +00:00
|
|
|
#include "TypeList.hpp"
|
|
|
|
|
|
|
|
namespace EC
|
|
|
|
{
|
|
|
|
namespace Meta
|
|
|
|
{
|
|
|
|
template <typename T, typename... Types>
|
|
|
|
struct ContainsHelper :
|
|
|
|
std::false_type
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
2016-03-14 08:53:57 +00:00
|
|
|
template <typename T, template <typename...> class TTypeList, typename Type, typename... Types>
|
|
|
|
struct ContainsHelper<T, TTypeList<Type, Types...> > :
|
2016-03-04 11:20:56 +00:00
|
|
|
std::conditional<
|
|
|
|
std::is_same<T, Type>::value,
|
|
|
|
std::true_type,
|
2016-03-14 08:53:57 +00:00
|
|
|
ContainsHelper<T, TTypeList<Types...> >
|
2016-03-04 11:20:56 +00:00
|
|
|
>::type
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename TTypeList>
|
2016-03-04 12:12:37 +00:00
|
|
|
using Contains = std::integral_constant<bool, ContainsHelper<T, TTypeList>::value>;
|
2016-03-04 11:20:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|