/*
* This file is part of libgim.
*
* libgim is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* libgim is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see .
*
* Copyright 2012 Danny Robson
*/
#ifndef __UTIL_TYPES_TRAITS_HPP
#define __UTIL_TYPES_TRAITS_HPP
#include
//-----------------------------------------------------------------------------
template struct is_dereferencable : std::false_type { };
template struct is_dereferencable : std::true_type { };
template struct is_dereferencable> : std::true_type { };
template struct is_dereferencable> : std::true_type { };
template struct is_dereferencable> : std::true_type { };
template struct is_dereferencable> : std::true_type { };
template struct dereferenced_type {
typedef typename std::enable_if<
std::is_pointer::value,
std::remove_pointer
>::type type;
};
//-----------------------------------------------------------------------------
template struct dereferenced_type> { typedef T type; };
template struct dereferenced_type> { typedef T type; };
template struct dereferenced_type> { typedef T type; };
template struct dereferenced_type> { typedef T type; };
template struct always_unsigned {
typedef typename std::make_unsigned::type type;
};
template <> struct always_unsigned { typedef double type; };
template <> struct always_unsigned { typedef float type; };
//-----------------------------------------------------------------------------
template struct is_lossless_cast : std::enable_if<
std::is_integral::value &&
std::is_integral::value &&
std::is_signed::value == std::is_signed::value &&
sizeof (T) <= sizeof (U),
std::true_type
>::value { };
#endif