Simplify traits.
This commit is contained in:
parent
2ca696d4df
commit
07ad14efdb
17
format.h
17
format.h
@ -120,7 +120,10 @@ void Array<T, SIZE>::append(const T *begin, const T *end) {
|
|||||||
// IntTraits is not specialized for integer types smaller than int,
|
// IntTraits is not specialized for integer types smaller than int,
|
||||||
// since these are promoted to int.
|
// since these are promoted to int.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct IntTraits {};
|
struct IntTraits {
|
||||||
|
typedef T UnsignedType;
|
||||||
|
static bool IsNegative(T) { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T, typename UnsignedT>
|
template <typename T, typename UnsignedT>
|
||||||
struct SignedIntTraits {
|
struct SignedIntTraits {
|
||||||
@ -128,24 +131,12 @@ struct SignedIntTraits {
|
|||||||
static bool IsNegative(T value) { return value < 0; }
|
static bool IsNegative(T value) { return value < 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct UnsignedIntTraits {
|
|
||||||
typedef T UnsignedType;
|
|
||||||
static bool IsNegative(T) { return false; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct IntTraits<int> : SignedIntTraits<int, unsigned> {};
|
struct IntTraits<int> : SignedIntTraits<int, unsigned> {};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct IntTraits<unsigned> : UnsignedIntTraits<unsigned> {};
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct IntTraits<long> : SignedIntTraits<long, unsigned long> {};
|
struct IntTraits<long> : SignedIntTraits<long, unsigned long> {};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct IntTraits<unsigned long> : UnsignedIntTraits<unsigned long> {};
|
|
||||||
|
|
||||||
class ArgInserter;
|
class ArgInserter;
|
||||||
class FormatterProxy;
|
class FormatterProxy;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user