Fix compilation errors on gcc 4.4

This commit is contained in:
Victor Zverovich 2018-02-28 07:47:24 -08:00
parent 698d909706
commit 45518c3fe1
2 changed files with 25 additions and 4 deletions

View File

@ -72,16 +72,27 @@
# endif # endif
#endif #endif
#if FMT_HAS_FEATURE(cxx_explicit_conversions)
# define FMT_EXPLICIT explicit
#else
# define FMT_EXPLICIT
#endif
#ifndef FMT_NULL #ifndef FMT_NULL
# if FMT_HAS_FEATURE(cxx_nullptr) || \ # if FMT_HAS_FEATURE(cxx_nullptr) || \
(FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || \ (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || \
FMT_MSC_VER >= 1600 FMT_MSC_VER >= 1600
# define FMT_NULL nullptr # define FMT_NULL nullptr
# define FMT_USE_NULLPTR 1
# else # else
# define FMT_NULL NULL # define FMT_NULL NULL
# endif # endif
#endif #endif
#ifndef FMT_USE_NULLPTR
# define FMT_USE_NULLPTR 0
#endif
// Check if exceptions are disabled. // Check if exceptions are disabled.
#if defined(__GNUC__) && !defined(__EXCEPTIONS) #if defined(__GNUC__) && !defined(__EXCEPTIONS)
# define FMT_EXCEPTIONS 0 # define FMT_EXCEPTIONS 0
@ -157,6 +168,11 @@
#endif #endif
namespace fmt { namespace fmt {
// An implementation of declval for pre-C++11 compilers such as gcc 4.
template <typename T>
typename std::add_rvalue_reference<T>::type declval() FMT_NOEXCEPT;
/** /**
\rst \rst
An implementation of ``std::basic_string_view`` for pre-C++17. It provides a An implementation of ``std::basic_string_view`` for pre-C++17. It provides a
@ -284,6 +300,8 @@ class basic_buffer {
std::size_t capacity_; std::size_t capacity_;
protected: protected:
typedef const T &const_reference;
basic_buffer(T *p = FMT_NULL, std::size_t size = 0, std::size_t capacity = 0) basic_buffer(T *p = FMT_NULL, std::size_t size = 0, std::size_t capacity = 0)
FMT_NOEXCEPT: ptr_(p), size_(size), capacity_(capacity) {} FMT_NOEXCEPT: ptr_(p), size_(size), capacity_(capacity) {}
@ -594,7 +612,10 @@ FMT_MAKE_VALUE(string_type, const std::basic_string<typename C::char_type>&,
basic_string_view<Char>) basic_string_view<Char>)
FMT_MAKE_VALUE(pointer_type, void*, const void*) FMT_MAKE_VALUE(pointer_type, void*, const void*)
FMT_MAKE_VALUE(pointer_type, const void*, const void*) FMT_MAKE_VALUE(pointer_type, const void*, const void*)
#if FMT_USE_NULLPTR
FMT_MAKE_VALUE(pointer_type, std::nullptr_t, const void*) FMT_MAKE_VALUE(pointer_type, std::nullptr_t, const void*)
#endif
// Formatting of arbitrary pointers is disallowed. If you want to output a // Formatting of arbitrary pointers is disallowed. If you want to output a
// pointer cast it to "void *" or "const void *". In particular, this forbids // pointer cast it to "void *" or "const void *". In particular, this forbids
@ -667,7 +688,7 @@ class basic_arg {
FMT_CONSTEXPR basic_arg() : type_(internal::none_type) {} FMT_CONSTEXPR basic_arg() : type_(internal::none_type) {}
explicit operator bool() const FMT_NOEXCEPT { FMT_EXPLICIT operator bool() const FMT_NOEXCEPT {
return type_ != internal::none_type; return type_ != internal::none_type;
} }
@ -891,7 +912,7 @@ template <typename Context, typename T>
class get_type { class get_type {
public: public:
typedef decltype(make_value<Context>( typedef decltype(make_value<Context>(
std::declval<typename std::decay<T>::type&>())) value_type; declval<typename std::decay<T>::type&>())) value_type;
static const type value = value_type::type_tag; static const type value = value_type::type_tag;
}; };

View File

@ -2093,7 +2093,7 @@ template <typename Range>
class arg_formatter: public internal::arg_formatter_base<Range> { class arg_formatter: public internal::arg_formatter_base<Range> {
private: private:
typedef typename Range::value_type char_type; typedef typename Range::value_type char_type;
typedef decltype(std::declval<Range>().begin()) iterator; typedef decltype(declval<Range>().begin()) iterator;
typedef internal::arg_formatter_base<Range> base; typedef internal::arg_formatter_base<Range> base;
typedef basic_context<iterator, char_type> context_type; typedef basic_context<iterator, char_type> context_type;
@ -2191,7 +2191,7 @@ template <typename Range>
class basic_writer { class basic_writer {
public: public:
typedef typename Range::value_type char_type; typedef typename Range::value_type char_type;
typedef decltype(std::declval<Range>().begin()) iterator; typedef decltype(declval<Range>().begin()) iterator;
typedef basic_format_specs<char_type> format_specs; typedef basic_format_specs<char_type> format_specs;
private: private: