mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Cleanup
This commit is contained in:
@ -60,6 +60,11 @@
|
|||||||
# define FMT_CUDA_VERSION 0
|
# define FMT_CUDA_VERSION 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC_LIBSTD__
|
||||||
|
# define FMT_GNUC_LIBSTD_VERSION \
|
||||||
|
(__GNUC_LIBSTD__ * 100 + __GNUC_LIBSTD_MINOR__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if FMT_GCC_VERSION || FMT_CLANG_VERSION
|
#if FMT_GCC_VERSION || FMT_CLANG_VERSION
|
||||||
# pragma GCC diagnostic push
|
# pragma GCC diagnostic push
|
||||||
|
|
||||||
@ -93,11 +98,6 @@
|
|||||||
# define FMT_HAS_BUILTIN(x) 0
|
# define FMT_HAS_BUILTIN(x) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC_LIBSTD__
|
|
||||||
# define FMT_GNUC_LIBSTD_VERSION \
|
|
||||||
(__GNUC_LIBSTD__ * 100 + __GNUC_LIBSTD_MINOR__)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FMT_THROW
|
#ifndef FMT_THROW
|
||||||
# if FMT_EXCEPTIONS
|
# if FMT_EXCEPTIONS
|
||||||
# if FMT_MSC_VER
|
# if FMT_MSC_VER
|
||||||
@ -125,8 +125,7 @@ FMT_END_NAMESPACE
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FMT_USE_USER_DEFINED_LITERALS
|
#ifndef FMT_USE_USER_DEFINED_LITERALS
|
||||||
// For Intel's compiler and NVIDIA's compiler both it and the system gcc/msc
|
// For Intel and NVIDIA compilers both they and the system gcc/msc support UDLs.
|
||||||
// must support UDLs.
|
|
||||||
# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \
|
# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \
|
||||||
FMT_MSC_VER >= 1900) && \
|
FMT_MSC_VER >= 1900) && \
|
||||||
(!(FMT_ICC_VERSION || FMT_CUDA_VERSION) || FMT_ICC_VERSION >= 1500 || \
|
(!(FMT_ICC_VERSION || FMT_CUDA_VERSION) || FMT_ICC_VERSION >= 1500 || \
|
||||||
@ -162,11 +161,11 @@ FMT_END_NAMESPACE
|
|||||||
// __builtin_clz is broken in clang with Microsoft CodeGen:
|
// __builtin_clz is broken in clang with Microsoft CodeGen:
|
||||||
// https://github.com/fmtlib/fmt/issues/519
|
// https://github.com/fmtlib/fmt/issues/519
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
# if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clz)
|
# if FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clz)
|
||||||
# define FMT_BUILTIN_CLZ(n) __builtin_clz(n)
|
# define FMT_BUILTIN_CLZ(n) __builtin_clz(n)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clzll)
|
# if FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clzll)
|
||||||
# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
|
# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@ -260,19 +259,8 @@ inline Dest bit_cast(const Source& source) {
|
|||||||
// An implementation of iterator_t for pre-C++20 systems.
|
// An implementation of iterator_t for pre-C++20 systems.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using iterator_t = decltype(std::begin(std::declval<T&>()));
|
using iterator_t = decltype(std::begin(std::declval<T&>()));
|
||||||
|
|
||||||
template <typename Allocator>
|
|
||||||
typename Allocator::value_type* allocate(Allocator& alloc, std::size_t n) {
|
|
||||||
#if __cplusplus >= 201103L || FMT_MSC_VER >= 1700
|
|
||||||
return std::allocator_traits<Allocator>::allocate(alloc, n);
|
|
||||||
#else
|
|
||||||
return alloc.allocate(n);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
template <typename Range> class basic_writer;
|
|
||||||
|
|
||||||
template <typename OutputIt, typename T = typename OutputIt::value_type>
|
template <typename OutputIt, typename T = typename OutputIt::value_type>
|
||||||
class output_range {
|
class output_range {
|
||||||
private:
|
private:
|
||||||
@ -294,17 +282,18 @@ class output_range {
|
|||||||
template <typename Container>
|
template <typename Container>
|
||||||
class back_insert_range
|
class back_insert_range
|
||||||
: public output_range<std::back_insert_iterator<Container>> {
|
: public output_range<std::back_insert_iterator<Container>> {
|
||||||
typedef output_range<std::back_insert_iterator<Container>> base;
|
using base = output_range<std::back_insert_iterator<Container>>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename Container::value_type value_type;
|
using value_type = typename Container::value_type;
|
||||||
|
|
||||||
back_insert_range(Container& c) : base(std::back_inserter(c)) {}
|
back_insert_range(Container& c) : base(std::back_inserter(c)) {}
|
||||||
back_insert_range(typename base::iterator it) : base(it) {}
|
back_insert_range(typename base::iterator it) : base(it) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef basic_writer<back_insert_range<internal::buffer<char>>> writer;
|
template <typename Range> class basic_writer;
|
||||||
typedef basic_writer<back_insert_range<internal::buffer<wchar_t>>> wwriter;
|
using writer = basic_writer<back_insert_range<internal::buffer<char>>>;
|
||||||
|
using wwriter = basic_writer<back_insert_range<internal::buffer<wchar_t>>>;
|
||||||
|
|
||||||
/** A formatting error such as invalid format string. */
|
/** A formatting error such as invalid format string. */
|
||||||
class format_error : public std::runtime_error {
|
class format_error : public std::runtime_error {
|
||||||
@ -472,7 +461,7 @@ void basic_memory_buffer<T, SIZE, Allocator>::grow(std::size_t size) {
|
|||||||
std::size_t new_capacity = old_capacity + old_capacity / 2;
|
std::size_t new_capacity = old_capacity + old_capacity / 2;
|
||||||
if (size > new_capacity) new_capacity = size;
|
if (size > new_capacity) new_capacity = size;
|
||||||
T* old_data = this->data();
|
T* old_data = this->data();
|
||||||
T* new_data = internal::allocate<Allocator>(*this, new_capacity);
|
T* new_data = std::allocator_traits<Allocator>::allocate(*this, new_capacity);
|
||||||
// The following code doesn't throw, so the raw pointer above doesn't leak.
|
// The following code doesn't throw, so the raw pointer above doesn't leak.
|
||||||
std::uninitialized_copy(old_data, old_data + this->size(),
|
std::uninitialized_copy(old_data, old_data + this->size(),
|
||||||
internal::make_checked(new_data, new_capacity));
|
internal::make_checked(new_data, new_capacity));
|
||||||
|
@ -52,7 +52,7 @@ template <typename Allocator> class allocator_ref {
|
|||||||
Allocator* get() const { return alloc_; }
|
Allocator* get() const { return alloc_; }
|
||||||
|
|
||||||
value_type* allocate(std::size_t n) {
|
value_type* allocate(std::size_t n) {
|
||||||
return fmt::internal::allocate(*alloc_, n);
|
return std::allocator_traits<Allocator>::allocate(*alloc_, n);
|
||||||
}
|
}
|
||||||
void deallocate(value_type* p, std::size_t n) { alloc_->deallocate(p, n); }
|
void deallocate(value_type* p, std::size_t n) { alloc_->deallocate(p, n); }
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user