#ifndef EOLIAN_CXX_META_HH_
#define EOLIAN_CXX_META_HH_

#include <utility>
#include <type_traits>

namespace efl { namespace eolian { namespace grammar { namespace meta {

template <std::size_t A0, std::size_t A1 = 0, std::size_t...args>
struct max : max<((A0 > A1) ? A0 : A1), args...> {};

template <std::size_t A0, std::size_t A1>
struct max<A0, A1> : std::integral_constant<std::size_t, (A0 > A1 ? A0 : A1)> {};

template <typename T>
struct identity { typedef T type; };

template <typename T, typename U, typename...Others>
struct is_one_of : std::conditional<std::is_same<T, U>::value
                                    , std::is_same<T, U>
                                    , is_one_of<T, Others...> >::type::type
{};

template <typename T, typename U>
struct is_one_of<T, U> : std::is_same<T, U>
{};


template <std::size_t size, typename T, typename U, typename...Args>
struct find_impl : find_impl<size+1, T, Args...>
{};

template <std::size_t size, typename T, typename...Args>
struct find_impl<size, T, T, Args...> : std::integral_constant<std::size_t, size> {};
  
template <typename T, typename U, typename...Args>
struct find : find_impl<0u, T, U, Args...>
{};

} } } }

#endif
