mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-02 11:28:20 +00:00
Remove conditional and to_iterator
This commit is contained in:
parent
1cade7ef4d
commit
c18a4041f9
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);
|
||||
};
|
||||
|
||||
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>
|
||||
class null_terminating_iterator;
|
||||
|
||||
@ -851,24 +845,6 @@ class null_terminating_iterator {
|
||||
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>
|
||||
const T *pointer_from(const T *p) { return p; }
|
||||
|
||||
@ -894,7 +870,7 @@ template <typename T>
|
||||
struct int_traits {
|
||||
// Smallest of uint32_t and uint64_t that is large enough to represent
|
||||
// all values of T.
|
||||
typedef typename conditional<
|
||||
typedef typename std::conditional<
|
||||
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
|
||||
operator()(U value) {
|
||||
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;
|
||||
if (sizeof(TargetType) <= sizeof(int)) {
|
||||
// Extra casts are used to silence warnings.
|
||||
|
@ -839,12 +839,3 @@ TEST(UtilTest, IsEnumConvertibleToInt) {
|
||||
EXPECT_TRUE(fmt::internal::convert_to_int<TestEnum>::enable_conversion);
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user