#pragma once
#ifndef __OPENCV_CUDEV_UTIL_TYPE_TRAITS_HPP__
#define __OPENCV_CUDEV_UTIL_TYPE_TRAITS_HPP__
#include "../common.hpp"
#include "vec_traits.hpp"
#include "detail/type_traits.hpp"
namespace cv { namespace cudev {
struct NullType {};
template <int A> struct Int2Type
{
enum { value = A };
};
template <typename T, int COUNT> struct ArrayWrapper
{
T array[COUNT];
};
template <int N, int CURRENT_VAL = N, int COUNT = 0> struct Log2
{
enum { value = Log2<N, (CURRENT_VAL >> 1), COUNT + 1>::VALUE };
};
template <int N, int COUNT> struct Log2<N, 0, COUNT>
{
enum { value = (1 << (COUNT - 1) < N) ? COUNT : COUNT - 1 };
};
template <int N> struct IsPowerOf2
{
enum { value = ((N != 0) && !(N & (N - 1))) };
};
template <bool, typename ThenType, typename ElseType> struct SelectIf
{
typedef ThenType type;
};
template <typename ThenType, typename ElseType> struct SelectIf<false, ThenType, ElseType>
{
typedef ElseType type;
};
template <bool, typename T = void> struct EnableIf {};
template <typename T> struct EnableIf<true, T> { typedef T type; };
template <bool, typename T = void> struct DisableIf {};
template <typename T> struct DisableIf<false, T> { typedef T type; };
template <typename A, typename B> struct TypesEquals
{
enum { value = 0 };
};
template <typename A> struct TypesEquals<A, A>
{
enum { value = 1 };
};
template <typename T> struct TypeTraits
{
typedef typename type_traits_detail::UnConst<T>::type non_const_type;
typedef typename type_traits_detail::UnVolatile<T>::type non_volatile_type;
typedef typename type_traits_detail::UnVolatile<typename type_traits_detail::UnConst<T>::type>::type unqualified_type;
typedef typename type_traits_detail::PointerTraits<unqualified_type>::type pointee_type;
typedef typename type_traits_detail::ReferenceTraits<T>::type referred_type;
enum { is_const = type_traits_detail::UnConst<T>::value };
enum { is_volatile = type_traits_detail::UnVolatile<T>::value };
enum { is_reference = type_traits_detail::ReferenceTraits<unqualified_type>::value };
enum { is_pointer = type_traits_detail::PointerTraits<typename type_traits_detail::ReferenceTraits<unqualified_type>::type>::value };
enum { is_unsigned_int = type_traits_detail::IsUnsignedIntegral<unqualified_type>::value };
enum { is_signed_int = type_traits_detail::IsSignedIntergral<unqualified_type>::value };
enum { is_integral = type_traits_detail::IsIntegral<unqualified_type>::value };
enum { is_float = type_traits_detail::IsFloat<unqualified_type>::value };
enum { is_scalar = is_integral || is_float };
enum { is_vec = type_traits_detail::IsVec<unqualified_type>::value };
typedef typename SelectIf<type_traits_detail::IsSimpleParameter<unqualified_type>::value,
T, typename type_traits_detail::AddParameterType<T>::type>::type parameter_type;
};
template <typename A, typename B> struct LargerType
{
typedef typename SelectIf<
unsigned(VecTraits<A>::cn) != unsigned(VecTraits<B>::cn),
void,
typename MakeVec<
typename type_traits_detail::LargerDepth<
typename VecTraits<A>::elem_type,
typename VecTraits<B>::elem_type
>::type,
VecTraits<A>::cn
>::type
>::type type;
};
}}
#endif