qminmax.h: move QTypeTraits part to qttypetraits.h
Makes sense to collect the stuff in a similarly-named header. Change-Id: Ic4190932a32fa06f1219473583327424dd2a8c11 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
358effb7a3
commit
ccb8efbfe5
@ -11,31 +11,10 @@
|
||||
|
||||
#include <QtCore/qassert.h>
|
||||
#include <QtCore/qtconfigmacros.h>
|
||||
|
||||
#include <type_traits>
|
||||
#include <QtCore/qttypetraits.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QTypeTraits {
|
||||
|
||||
namespace detail {
|
||||
template<typename T, typename U,
|
||||
typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
|
||||
std::is_floating_point_v<T> == std::is_floating_point_v<U> &&
|
||||
std::is_signed_v<T> == std::is_signed_v<U> &&
|
||||
!std::is_same_v<T, bool> && !std::is_same_v<U, bool> &&
|
||||
!std::is_same_v<T, char> && !std::is_same_v<U, char>>>
|
||||
struct Promoted
|
||||
{
|
||||
using type = decltype(T() + U());
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
using Promoted = typename detail::Promoted<T, U>::type;
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
constexpr inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
|
||||
template <typename T>
|
||||
|
@ -60,6 +60,26 @@ template <typename T> struct type_dependent_false : std::false_type {};
|
||||
template <auto T> struct value_dependent_false : std::false_type {};
|
||||
}
|
||||
|
||||
namespace QTypeTraits {
|
||||
|
||||
namespace detail {
|
||||
template<typename T, typename U,
|
||||
typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
|
||||
std::is_floating_point_v<T> == std::is_floating_point_v<U> &&
|
||||
std::is_signed_v<T> == std::is_signed_v<U> &&
|
||||
!std::is_same_v<T, bool> && !std::is_same_v<U, bool> &&
|
||||
!std::is_same_v<T, char> && !std::is_same_v<U, char>>>
|
||||
struct Promoted
|
||||
{
|
||||
using type = decltype(T() + U());
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
using Promoted = typename detail::Promoted<T, U>::type;
|
||||
|
||||
} // namespace QTypeTraits
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QTTYPETRAITS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user