diff --git a/doc/syntax.md b/doc/syntax.md index b628a56f..ac512823 100644 --- a/doc/syntax.md +++ b/doc/syntax.md @@ -251,7 +251,7 @@ The available integer presentation types are: 'b' Binary format. Outputs the number in base 2. Using the '#' - option with this type adds the prefix "0b" to the output value. + option with this type adds the prefix "0b" to the output value. @@ -768,9 +768,9 @@ fmt::print("{:n:f}", std::array{std::numbers::pi, std::numbers::e}); ## Format Examples This section contains examples of the format syntax and comparison with -the printf formatting. +the `printf` formatting. -In most of the cases the syntax is similar to the printf formatting, +In most of the cases the syntax is similar to the `printf` formatting, with the addition of the `{}` and with `:` used instead of `%`. For example, `"%03.2f"` can be translated to `"{:03.2f}"`. diff --git a/include/fmt/format.h b/include/fmt/format.h index 5333eb51..0cd3a232 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -40,6 +40,12 @@ #include "base.h" +// libc++ supports string_view in pre-c++17. +#if FMT_HAS_INCLUDE() && \ + (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION)) +# define FMT_USE_STRING_VIEW +#endif + #ifndef FMT_MODULE # include // malloc, free @@ -62,11 +68,8 @@ # include // std::bit_cast # endif -// libc++ supports string_view in pre-c++17. -# if FMT_HAS_INCLUDE() && \ - (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION)) +# if defined(FMT_USE_STRING_VIEW) # include -# define FMT_USE_STRING_VIEW # endif # if FMT_MSC_VERSION