From e7f13d05b873bc39c21ab6a1df1278a2ab152ac5 Mon Sep 17 00:00:00 2001 From: Nicolas Fauvet Date: Thu, 19 Jan 2017 11:18:37 +0100 Subject: [PATCH] make code c++98 compatible --- fmt/format.h | 8 ++++++++ fmt/ostream.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/fmt/format.h b/fmt/format.h index 58b416be..dc291aab 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -267,6 +267,14 @@ typedef __int64 intmax_t; (FMT_GCC_VERSION >= 303 && FMT_HAS_GXX_CXX11)) #endif +// Checks if decltype v1.1 is supported +// http://en.cppreference.com/w/cpp/compiler_support +#define FMT_HAS_DECLTYPE_INCOMPLETE_RETURN_TYPES \ + (FMT_HAS_FEATURE(cxx_decltype_incomplete_return_types) || \ + (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || \ + FMT_MSC_VER >= 1900 || \ + FMT_ICC_VERSION >= 1200) + #ifdef FMT_HEADER_ONLY // If header only do not use extern templates. # undef FMT_USE_EXTERN_TEMPLATES diff --git a/fmt/ostream.h b/fmt/ostream.h index 7559547d..d7a9a9e2 100644 --- a/fmt/ostream.h +++ b/fmt/ostream.h @@ -74,6 +74,7 @@ struct ConvertToIntImpl { // Write the content of w to os. void write(std::ostream &os, Writer &w); +#ifdef FMT_HAS_DECLTYPE_INCOMPLETE_RETURN_TYPES template class is_streamable { template @@ -85,6 +86,7 @@ class is_streamable { public: static constexpr bool value = decltype(test(0))::value; }; +#endif } // namespace internal // Formats a value. @@ -123,7 +125,9 @@ typename std::enable_if< BasicWriter& >::type operator<<(BasicWriter &writer, const T &value) { +#ifdef FMT_HAS_DECLTYPE_INCOMPLETE_RETURN_TYPES static_assert(internal::is_streamable::value, "T must be Streamable"); +#endif auto &buffer = writer.buffer(); Char *start = &buffer[0] + buffer.size();