mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 02:37:36 +02:00
Remove conditional and to_iterator
This commit is contained in:
26
fmt/format.h
26
fmt/format.h
@ -768,12 +768,6 @@ class char_traits<wchar_t> : public basic_char_traits<wchar_t> {
|
|||||||
const wchar_t *format, unsigned width, int precision, T value);
|
const wchar_t *format, unsigned width, int precision, T value);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <bool B, class T, class F>
|
|
||||||
struct conditional { typedef T type; };
|
|
||||||
|
|
||||||
template<class T, class F>
|
|
||||||
struct conditional<false, T, F> { typedef F type; };
|
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
class null_terminating_iterator;
|
class null_terminating_iterator;
|
||||||
|
|
||||||
@ -851,24 +845,6 @@ class null_terminating_iterator {
|
|||||||
const Char *end_;
|
const Char *end_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <
|
|
||||||
typename T,
|
|
||||||
typename Char,
|
|
||||||
typename std::enable_if<
|
|
||||||
std::is_same<T, null_terminating_iterator<Char>>::value, int>::type = 0>
|
|
||||||
null_terminating_iterator<Char> to_iterator(basic_string_view<Char> v) {
|
|
||||||
const Char *s = v.data();
|
|
||||||
return null_terminating_iterator<Char>(s, s + v.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <
|
|
||||||
typename T,
|
|
||||||
typename Char,
|
|
||||||
typename std::enable_if<std::is_same<T, const Char*>::value, int>::type = 0>
|
|
||||||
const Char *to_iterator(basic_string_view<Char> v) {
|
|
||||||
return v.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T *pointer_from(const T *p) { return p; }
|
const T *pointer_from(const T *p) { return p; }
|
||||||
|
|
||||||
@ -894,7 +870,7 @@ template <typename T>
|
|||||||
struct int_traits {
|
struct int_traits {
|
||||||
// Smallest of uint32_t and uint64_t that is large enough to represent
|
// Smallest of uint32_t and uint64_t that is large enough to represent
|
||||||
// all values of T.
|
// all values of T.
|
||||||
typedef typename conditional<
|
typedef typename std::conditional<
|
||||||
std::numeric_limits<T>::digits <= 32, uint32_t, uint64_t>::type main_type;
|
std::numeric_limits<T>::digits <= 32, uint32_t, uint64_t>::type main_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class ArgConverter {
|
|||||||
typename std::enable_if<std::is_integral<U>::value>::type
|
typename std::enable_if<std::is_integral<U>::value>::type
|
||||||
operator()(U value) {
|
operator()(U value) {
|
||||||
bool is_signed = type_ == 'd' || type_ == 'i';
|
bool is_signed = type_ == 'd' || type_ == 'i';
|
||||||
typedef typename internal::conditional<
|
typedef typename std::conditional<
|
||||||
std::is_same<T, void>::value, U, T>::type TargetType;
|
std::is_same<T, void>::value, U, T>::type TargetType;
|
||||||
if (sizeof(TargetType) <= sizeof(int)) {
|
if (sizeof(TargetType) <= sizeof(int)) {
|
||||||
// Extra casts are used to silence warnings.
|
// Extra casts are used to silence warnings.
|
||||||
|
@ -839,12 +839,3 @@ TEST(UtilTest, IsEnumConvertibleToInt) {
|
|||||||
EXPECT_TRUE(fmt::internal::convert_to_int<TestEnum>::enable_conversion);
|
EXPECT_TRUE(fmt::internal::convert_to_int<TestEnum>::enable_conversion);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST(UtilTest, Conditional) {
|
|
||||||
int i = 0;
|
|
||||||
fmt::internal::conditional<true, int, char>::type *pi = &i;
|
|
||||||
(void)pi;
|
|
||||||
char c = 0;
|
|
||||||
fmt::internal::conditional<false, int, char>::type *pc = &c;
|
|
||||||
(void)pc;
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user