mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-19 20:18:49 +00:00
Detect the availability of initialize lists.
This commit is contained in:
parent
bd5fe67eef
commit
3d7faaf0bd
20
format.h
20
format.h
@ -42,8 +42,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#if FMT_USE_CXX11
|
#ifdef __GNUC__
|
||||||
# include <initializer_list>
|
# define FMG_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Compatibility with compilers other than clang.
|
// Compatibility with compilers other than clang.
|
||||||
@ -51,16 +51,22 @@
|
|||||||
# define __has_feature(x) 0
|
# define __has_feature(x) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define FMT_USE_INITIALIZER_LIST \
|
||||||
|
(__has_feature(cxx_generalized_initializers) || \
|
||||||
|
FMG_GCC_VERSION >= 404 || _MSC_VER >= 1700)
|
||||||
|
|
||||||
|
#if FMT_USE_INITIALIZER_LIST
|
||||||
|
# include <initializer_list>
|
||||||
|
#endif
|
||||||
|
|
||||||
// Define FMT_USE_NOEXCEPT to make format use noexcept (C++11 feature).
|
// Define FMT_USE_NOEXCEPT to make format use noexcept (C++11 feature).
|
||||||
#if FMT_USE_NOEXCEPT || \
|
#if FMT_USE_NOEXCEPT || __has_feature(cxx_noexcept) || FMG_GCC_VERSION >= 408
|
||||||
(defined(__has_feature) && __has_feature(cxx_noexcept)) || \
|
|
||||||
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
|
|
||||||
# define FMT_NOEXCEPT(expr) noexcept(expr)
|
# define FMT_NOEXCEPT(expr) noexcept(expr)
|
||||||
#else
|
#else
|
||||||
# define FMT_NOEXCEPT(expr)
|
# define FMT_NOEXCEPT(expr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
#if FMG_GCC_VERSION >= 406
|
||||||
# define FMT_GCC_DIAGNOSTIC
|
# define FMT_GCC_DIAGNOSTIC
|
||||||
# pragma GCC diagnostic push
|
# pragma GCC diagnostic push
|
||||||
# pragma GCC diagnostic ignored "-Wlong-long"
|
# pragma GCC diagnostic ignored "-Wlong-long"
|
||||||
@ -999,7 +1005,7 @@ class BasicFormatter {
|
|||||||
BasicFormatter(BasicWriter<Char> &w, const Char *format = 0)
|
BasicFormatter(BasicWriter<Char> &w, const Char *format = 0)
|
||||||
: writer_(&w), format_(format) {}
|
: writer_(&w), format_(format) {}
|
||||||
|
|
||||||
#if FMT_USE_CXX11
|
#if FMT_USE_INITIALIZER_LIST
|
||||||
// Constructs a formatter with formatting arguments.
|
// Constructs a formatter with formatting arguments.
|
||||||
BasicFormatter(BasicWriter<Char> &w,
|
BasicFormatter(BasicWriter<Char> &w,
|
||||||
const Char *format, std::initializer_list<Arg> args)
|
const Char *format, std::initializer_list<Arg> args)
|
||||||
|
Loading…
Reference in New Issue
Block a user