Skip to content

Commit

Permalink
Squashed 'lib/fmt/' changes from 17dda583..b6f4ceae
Browse files Browse the repository at this point in the history
REVERT: 17dda583 constexpr -> const for portability
REVERT: 7ffe87c0 Fix docs
REVERT: 3c4273dd Simplify UDL
REVERT: 36d95c9f Fix docs
REVERT: 44abd1f4 Update signatures in docs and ostream.h
REVERT: db745986 Workaround broken std::numeric_limits
REVERT: 8271e43e Improve __float128 support and use constexpr
REVERT: 3f9b7433 Improve __float128 support
REVERT: 71778e8b Specialize float_info for __float128
REVERT: f024565c Improve exponent handling in Dragon
REVERT: e7f31f5c Cleanup format_dragon
REVERT: 3c61799f Cleanup fuzzing mode
REVERT: 4e39e130 Remove xchar.h include from ostream.h
REVERT: ac0d9d5f Issue #2816: also strip named-arg for the fallback formatter
REVERT: 4ad90578 Fix #2818: diagnose unformattable arguments in unpacked case
REVERT: 17ba99c1 Fix #2817: add compile-time checking to ostream overloads of fmt::print
REVERT: 3d19be28 Fix #2816: strip named argument wrappers for compile-time checking
REVERT: c076a54a Move snprintf_float to format.h
REVERT: 0419d238 Add FMT_USE_FLOAT128
REVERT: 69396347 Update color.h (#2815)
REVERT: c51604a0 Reduce the number of configs
REVERT: 587dc994 Remove windows-2016 env no longer suppported by GA
REVERT: 1f3d44b8 Update std::tm/chrono docs
REVERT: bc654faf Add is_floating_point that works with __float128
REVERT: 26bffce6 Simplify basic_memory_buffer
REVERT: ed18ca3e Implement isnan
REVERT: a204b8dd Add initial __float128 support
REVERT: b6b003b0 Cleanup test
REVERT: f2543b0a Add initial support for 128-bit floats
REVERT: 72f48756 Simplify float_info
REVERT: f91f61cd Reuse num_significand_bits
REVERT: 9a1beab5 Workaround Windows API garbage
REVERT: a8fe8bec Fix compilation error for ranges with ADL `begin`/`end` (#2807)
REVERT: f6bcb25e Remove extra dot
REVERT: b4a4189d Fix handling of implicit bit
REVERT: 32d477e5 Add `styled` in documentation (#2805)
REVERT: 0b7c045a Simplify _cf
REVERT: c10fffec Make _cf visible in the doc build
REVERT: dcfbe4a7 Document output_file default behavior correctly (#2803)
REVERT: 8c9bc070 Implement styled arguments (#2793)
REVERT: 5bc39d36 Eliminate intel compiler warnings (#2802)
REVERT: e3d688e7 Fix warning C4251: class fmt::v8::file needs to have dll-interface (#2797)
REVERT: 8d4f3e91 Update docs
REVERT: 0cef1f81 Fixing formatting of certain kinds of ranges of ranges. (#2787)
REVERT: 5c0d6564 Fix apt install
REVERT: d416a995 Update README.rst
REVERT: 3f67a124 Update README.rst
REVERT: cc57e359 Update godbolt link in the readme (#2789)
REVERT: 86477f7e Fix size computation
REVERT: 0742606f Fix Conversion Warning (#2782)
REVERT: 1ba69fb5 Remove snprintf FP fallback
REVERT: ea6f0bf0 Minor cleanup
REVERT: 1a18a2f3 Fixing "C4127: conditional expression is constant" Visual Studio 2022 warning in pedantic mode (#2783)
REVERT: 4fcacea3 Parameterized fp on significand type
REVERT: cf940ae8 Simplify to_decimal
REVERT: 70dc3de0 Update format.h
REVERT: cbc59ca8 Clear moved from memory buffer
REVERT: ea3d326c Fix clang -Wliteral-range warning (#2779)
REVERT: aad44f28 Add fmt::enums::format_as
REVERT: 1319719a Add underlying_t
REVERT: af5d8004 Limit Dragonbox to supported FP formats
REVERT: 7b964209 Remove unused include
REVERT: a0b43bfa Add support for 96-bit long double
REVERT: 2c8cd2db Fix handling of zero precision
REVERT: b6d56170 Remove unnecessary inline
REVERT: 05432e57 Use consistent indentation
REVERT: 47da218c Remove uintptr_fallback
REVERT: 4ddab890 Merge accumulator into int128_fallback
REVERT: d38f72af Refactor fallback ints
REVERT: 15c2a3ba int128_t -> int128_opt
REVERT: 532a69a6 Fix handling of 96-bit long double with -m32
REVERT: d8e1dd4a improve installing headers
REVERT: ae25f796 add ability to build Apple framework using CMAKE_FRAMEWORK
REVERT: ce93a66d Implement a fallback uint128_t
REVERT: 6a134640 Include 128-bit with other signed integers in specifier check
REVERT: 70de324a Apply 2746 fix for NVidia compiler also (#2770)
REVERT: a1ea3e01 Move built-in formatter specialization to core
REVERT: 161059dd Add support for extended precision FP
REVERT: c4c6b42d Bump version
REVERT: 21785040 Fix markup
REVERT: 2b6f7fc7 Add partial support for extended precision FP
REVERT: 0a24a071 Clz builtin may be not constexpr (Issue #2761) (#2762)
REVERT: ba6f89c7 Update .bazelversion (#2766)
REVERT: 5594edaf Address fmtlib/fmt#2763 (#2765)
REVERT: 10e3b83a Replace ``make_args_checked`` with ``make_format_args`` (#2760)
REVERT: c48353cb Update docs
REVERT: 083510f0 Add FMT_CONSTEXPR to rotr instead
REVERT: dba99bc8 Revert adding constexpr to rotr to satisfy C++11 compilers
REVERT: c04af4bf Simplify remove_trailing_zeros
REVERT: b348caa9 Remove some C-style casts for consistency
REVERT: c8bd1e64 Simplify remove_trailing_zeros
REVERT: 9b23e9dc Fix wrong comment/refer to a correct reference
REVERT: 69f2c550 Remove std:: infront of uint32_t/64_t & add constexpr to rotr
REVERT: 9b62310f Fix some conversion issues
REVERT: 08d12f31 Fix typo
REVERT: dbddb1d0 Remove literal separator to satisfy some compilers
REVERT: 7dbe3dcd Recover log10_2_significand
REVERT: 10642e60 Optimize remove_trailing_zeros
REVERT: 7b4323e1 Add rotr
REVERT: f1bd6f77 Check r < deltai first, because that is the major branch chosen for short inputs
REVERT: 5d8eb6a1 Reflect the new paper   - Change constants appearing in log & division computations   - Rename beta_minus_1 to beta
REVERT: 8e2e4d40 Suppress a gcc warning
REVERT: a44716f5 Workaround to Intel compiler (#2758)
REVERT: c71b0701 Add missing const qualifier (#2755)
REVERT: ecd6022c Update docs
REVERT: afbcf1e8 Remove legacy C locale wrapper
REVERT: 90325d09 Fix stored type detection
REVERT: e2ba01fc Fix overload ambiguity in print
REVERT: 17b362f7 Simplify ostream opt-in API
REVERT: a5a7e3a2 Update docs
REVERT: f055ebbd Make ostream operators opt in to reduce the risk of ODR violations
REVERT: 8a21e328 Remove problematic constructibility check
REVERT: 31e743d0 Don't use ostream for types convertible to string_view
REVERT: 35c0286c Simplify byte handling
REVERT: c7173a36 Drop :: and fix formatting
REVERT: 3e8372b9 qualify unqualified calls to format in compile.h (#2742)
REVERT: a34a97cc Supporting ? as a string presentation type (#2674)
REVERT: ae1aaaee Fix access mode of files created (#2530) (#2733)
REVERT: 1557ab76 Add format_as for enums
REVERT: b00a1eac Fixes NVIDIA HPC compiler and Intel ICC compatibility (#2732)
REVERT: a7aecbfc Remove an old mingw workaround
REVERT: dfcc730c Making target_compile_options PRIVATE, fix #2726, fix #2507
REVERT: f7a809be Clarify the choice of magic numbers and compute the most magic one
REVERT: 09fde7f4 Add fmt::underlying for enum classes
REVERT: 0014024a Don't rely on transitive includes
REVERT: c2850055 FMT_NOEXCEPT -> noexcept
REVERT: 6240d020 Improve comments
REVERT: 925b744a Improve comments
REVERT: 22b14ff2 Simplify cache recovery
REVERT: 3dc26b44 Make a fallback path more compiler-friendly
REVERT: 2e4038bf Simplify lines with __builtin_addcll and friends
REVERT: 76336b4f Replace noexcept with FMT_NOEXCEPT
REVERT: 91819834 Fix syntax errors
REVERT: 74097a14 Remove now-unused stuffs
REVERT: 21a1c533 Fix typo
REVERT: 04eea0f0 Remove now-unused stuffs
REVERT: 35a468ed Simplify integer checks
REVERT: 1882a7a2 Replace Dragonbox cache which allows simpler cache recovery & integer checks
REVERT: f4dd1b1b Simplify Dragonbox Step 3.
REVERT: 70561ed1 Minimize the usage of built-in 128-bit ints It usually generates slower code than manual handling.
REVERT: cdf1a3b5 Fix codecvt warning (#2408) (#2725)
REVERT: b8b037e9 Fix -Wconversion warning  (#2724)
REVERT: 5985f0a7 Fix overflow for chrono durations (#2722)
REVERT: 8f8a1a02 Fix handling of formattable types implicitly convertible to pointers
REVERT: b02e5af5 fmt::join support FMT_COMPILE (#2720)
REVERT: 58fb7823 Improve docs
REVERT: 4fe6129d Fix FMT_NOEXCEPT definition
REVERT: c056a009 Docs: Fix link to "Compile-time Format String Checks" section (#2712)
REVERT: 7c12118c Deprecate buffered_file::fileno
REVERT: 2a09d468 Use noexcept unconditionally
REVERT: a126b4d8 Check if right shift is arithmetic
REVERT: 9ff91b18 Simplify write_fractional_seconds
REVERT: d9f045fb Fix a UB in chrono
REVERT: c06bef72 Adding comments for range formatting. (#2706)
REVERT: 3c98f1a4 Comment style
REVERT: 6e0f1399 Supporting nested format specs for ranges. (#2673)
REVERT: 0102101a Make colored print handle UTF-8 (#2701)
REVERT: 4ac5269b Update ChangeLog.rst

git-subtree-dir: lib/fmt
git-subtree-split: b6f4ceaed0a0a24ccf575fab6c56dd50ccf6f1a9
  • Loading branch information
Nazar-Hordii committed Mar 24, 2022
1 parent af531ef commit 29eb8e8
Show file tree
Hide file tree
Showing 40 changed files with 2,263 additions and 2,458 deletions.
1 change: 0 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
- name: Create Build Environment
run: |
${{matrix.install}}
sudo apt update
sudo apt install locales-all
cmake -E make_directory ${{runner.workspace}}/build
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@ jobs:
runs-on: ${{matrix.os}}
strategy:
matrix:
# windows-2019 has MSVC 2019 installed:
# https://github.com/actions/virtual-environments.
os: [windows-2019]
# windows-2016 and windows-2019 have MSVC 2017 and 2019 installed
# respectively: https://github.com/actions/virtual-environments.
os: [windows-2016, windows-2019]
platform: [Win32, x64]
build_type: [Debug, Release]
standard: [11, 17, 20]
include:
- os: windows-2019
- os: windows-2016
platform: Win32
build_type: Debug
shared: -DBUILD_SHARED_LIBS=ON
exclude:
- os: windows-2016
platform: Win32
- os: windows-2016
standard: 17
- os: windows-2016
standard: 20
- os: windows-2019
standard: 11
platform: Win32
- os: windows-2019
standard: 20
platform: Win32
Expand Down
27 changes: 24 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ if (FMT_MASTER_PROJECT AND CMAKE_GENERATOR MATCHES "Visual Studio")
${CMAKE_MAKE_PROGRAM} -p:FrameworkPathOverride=\"${netfxpath}\" %*")
endif ()

set(strtod_l_headers stdlib.h)
if (APPLE)
set(strtod_l_headers ${strtod_l_headers} xlocale.h)
endif ()

include(CheckSymbolExists)
if (WIN32)
check_symbol_exists(_strtod_l "${strtod_l_headers}" HAVE_STRTOD_L)
else ()
check_symbol_exists(strtod_l "${strtod_l_headers}" HAVE_STRTOD_L)
endif ()

function(add_headers VAR)
set(headers ${${VAR}})
foreach (header ${ARGN})
Expand All @@ -232,6 +244,17 @@ endif ()
add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} README.rst ChangeLog.rst)
add_library(fmt::fmt ALIAS fmt)

if (HAVE_STRTOD_L)
target_compile_definitions(fmt PUBLIC FMT_LOCALE)
endif ()

if (MINGW)
check_cxx_compiler_flag("-Wa,-mbig-obj" FMT_HAS_MBIG_OBJ)
if (${FMT_HAS_MBIG_OBJ})
target_compile_options(fmt PUBLIC "-Wa,-mbig-obj")
endif()
endif ()

if (FMT_WERROR)
target_compile_options(fmt PRIVATE ${WERROR_FLAG})
endif ()
Expand All @@ -252,7 +275,6 @@ set(FMT_DEBUG_POSTFIX d CACHE STRING "Debug library postfix.")

set_target_properties(fmt PROPERTIES
VERSION ${FMT_VERSION} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}
PUBLIC_HEADER "${FMT_HEADERS}"
DEBUG_POSTFIX "${FMT_DEBUG_POSTFIX}")

# Set FMT_LIB_NAME for pkg-config fmt.pc. We cannot use the OUTPUT_NAME target
Expand Down Expand Up @@ -330,8 +352,6 @@ if (FMT_INSTALL)
install(TARGETS ${INSTALL_TARGETS} EXPORT ${targets_export_name}
LIBRARY DESTINATION ${FMT_LIB_DIR}
ARCHIVE DESTINATION ${FMT_LIB_DIR}
PUBLIC_HEADER DESTINATION "${FMT_INC_DIR}/fmt"
FRAMEWORK DESTINATION "."
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

# Use a namespace because CMake provides better diagnostics for namespaced
Expand All @@ -348,6 +368,7 @@ if (FMT_INSTALL)

install(FILES $<TARGET_PDB_FILE:${INSTALL_TARGETS}>
DESTINATION ${FMT_LIB_DIR} OPTIONAL)
install(FILES ${FMT_HEADERS} DESTINATION "${FMT_INC_DIR}/fmt")
install(FILES "${pkgconfig}" DESTINATION "${FMT_PKGCONFIG_DIR}")
endif ()

Expand Down
2 changes: 1 addition & 1 deletion ChangeLog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
`#2696 <https://github.com/fmtlib/fmt/pull/2696>`_).
Thanks `@saraedum (Julian Rüth) <https://github.com/saraedum>`_.

* Fixed chrono formatting on big endian systems
* Fixed chorno formatting on big endian systems
(`#2698 <https://github.com/fmtlib/fmt/issues/2698>`_,
`#2699 <https://github.com/fmtlib/fmt/pull/2699>`_).
Thanks `@phprus (Vladislav Shchapov) <https://github.com/phprus>`_ and
Expand Down
13 changes: 6 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.. image:: https://user-images.githubusercontent.com/
576385/156254208-f5b743a9-88cf-439d-b0c0-923d53e8d551.png
:width: 25%
:alt: {fmt}
{fmt}
=====

.. image:: https://github.com/fmtlib/fmt/workflows/linux/badge.svg
:target: https://github.com/fmtlib/fmt/actions?query=workflow%3Alinux
Expand All @@ -28,8 +26,9 @@
**{fmt}** is an open-source formatting library providing a fast and safe
alternative to C stdio and C++ iostreams.

If you like this project, please consider donating to one of the funds that
help victims of the war in Ukraine: https://www.stopputin.net/.
If you like this project, please consider donating to the BYSOL
Foundation that helps victims of political repressions in Belarus:
https://bysol.org/en/bs/general/.

`Documentation <https://fmt.dev>`__

Expand Down Expand Up @@ -124,7 +123,7 @@ Output::
Default format: 42s 100ms
strftime-like format: 03:15:30

**Print a container** (`run <https://godbolt.org/z/MxM1YqjE7>`_)
**Print a container** (`run <https://godbolt.org/z/MjsY7c>`_)

.. code:: c++

Expand Down
50 changes: 20 additions & 30 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ binary footprint, for example (https://godbolt.org/z/oba4Mc):

template <typename S, typename... Args>
void log(const char* file, int line, const S& format, Args&&... args) {
vlog(file, line, format, fmt::make_format_args(args...));
vlog(file, line, format,
fmt::make_args_checked<Args...>(format, args...));
}

#define MY_LOG(format, ...) \
Expand All @@ -124,6 +125,8 @@ binary footprint, for example (https://godbolt.org/z/oba4Mc):
Note that ``vlog`` is not parameterized on argument types which improves compile
times and reduces binary code size compared to a fully parameterized version.

.. doxygenfunction:: fmt::make_args_checked(const S&, const remove_reference_t<Args>&...)

.. doxygenfunction:: fmt::make_format_args(const Args&...)

.. doxygenclass:: fmt::format_arg_store
Expand Down Expand Up @@ -179,11 +182,6 @@ functions and locale support.
Formatting User-defined Types
-----------------------------

The {fmt} library provides formatters for many standard C++ types.
See :ref:`fmt/ranges.h <ranges-api>` for ranges and tuples including standard
containers such as ``std::vector`` and :ref:`fmt/chrono.h <chrono-api>` for date
and time formatting.

To make a user-defined type formattable, specialize the ``formatter<T>`` struct
template and implement ``parse`` and ``format`` methods::

Expand Down Expand Up @@ -224,7 +222,7 @@ template and implement ``parse`` and ``format`` methods::
// Formats the point p using the parsed format specification (presentation)
// stored in this formatter.
template <typename FormatContext>
auto format(const point& p, FormatContext& ctx) const -> decltype(ctx.out()) {
auto format(const point& p, FormatContext& ctx) -> decltype(ctx.out()) {
// ctx.out() is an output iterator to write to.
return presentation == 'f'
? format_to(ctx.out(), "({:.1f}, {:.1f})", p.x, p.y)
Expand All @@ -246,7 +244,7 @@ example::
template <> struct fmt::formatter<color>: formatter<string_view> {
// parse is inherited from formatter<string_view>.
template <typename FormatContext>
auto format(color c, FormatContext& ctx) const {
auto format(color c, FormatContext& ctx) {
string_view name = "unknown";
switch (c) {
case color::red: name = "red"; break;
Expand Down Expand Up @@ -284,7 +282,7 @@ You can also write a formatter for a hierarchy of classes::
struct fmt::formatter<T, std::enable_if_t<std::is_base_of<A, T>::value, char>> :
fmt::formatter<std::string> {
template <typename FormatCtx>
auto format(const A& a, FormatCtx& ctx) const {
auto format(const A& a, FormatCtx& ctx) {
return fmt::formatter<std::string>::format(a.name(), ctx);
}
};
Expand All @@ -309,7 +307,7 @@ The following user-defined literals are defined in ``fmt/format.h``.

.. doxygenfunction:: operator""_format(const char *s, size_t n) -> detail::udl_formatter<char>

.. doxygenfunction:: operator""_a()
.. doxygenfunction:: operator""_a(const char *s, size_t) -> detail::udl_arg<char>

Utilities
---------
Expand All @@ -318,8 +316,6 @@ Utilities
.. doxygenfunction:: fmt::ptr(const std::unique_ptr<T> &p) -> const void*
.. doxygenfunction:: fmt::ptr(const std::shared_ptr<T> &p) -> const void*

.. doxygenfunction:: fmt::underlying(Enum e) -> typename std::underlying_type<Enum>::type

.. doxygenfunction:: fmt::to_string(const T &value) -> std::string

.. doxygenfunction:: fmt::to_string_view(const Char *s) -> basic_string_view<Char>
Expand Down Expand Up @@ -450,19 +446,16 @@ The format syntax is described in :ref:`chrono-specs`.
Format string compilation
=========================

``fmt/compile.h`` provides format string compilation enabled via the
``FMT_COMPILE`` macro or the ``_cf`` user-defined literal. Format strings
marked with ``FMT_COMPILE`` or ``_cf`` are parsed, checked and converted into
efficient formatting code at compile-time. This supports arguments of built-in
and string types as well as user-defined types with ``constexpr`` ``parse``
functions in their ``formatter`` specializations. Format string compilation can
generate more binary code compared to the default API and is only recommended in
places where formatting is a performance bottleneck.
``fmt/compile.h`` provides format string compilation support when using
``FMT_COMPILE``. Format strings are parsed, checked and converted into efficient
formatting code at compile-time. This supports arguments of built-in and string
types as well as user-defined types with ``constexpr`` ``parse`` functions in
their ``formatter`` specializations. Format string compilation can generate more
binary code compared to the default API and is only recommended in places where
formatting is a performance bottleneck.

.. doxygendefine:: FMT_COMPILE

.. doxygenfunction:: operator""_cf()

.. _color-api:

Terminal color and text style
Expand All @@ -476,8 +469,6 @@ Terminal color and text style

.. doxygenfunction:: bg(detail::color_type)

.. doxygenfunction:: styled(const T& value, text_style ts)

.. _os-api:

System APIs
Expand All @@ -495,9 +486,7 @@ System APIs
========================

``fmt/ostream.h`` provides ``std::ostream`` support including formatting of
user-defined types that have an overloaded insertion operator (``operator<<``).
In order to make a type formattable via ``std::ostream`` you should provide a
``formatter`` specialization inherited from ``ostream_formatter``::
user-defined types that have an overloaded insertion operator (``operator<<``)::

#include <fmt/ostream.h>

Expand All @@ -511,12 +500,13 @@ In order to make a type formattable via ``std::ostream`` you should provide a
}
};

template <> struct fmt::formatter<date> : ostream_formatter {};

std::string s = fmt::format("The date is {}", date(2012, 12, 9));
// s == "The date is 2012-12-9"

.. doxygenfunction:: print(std::ostream &os, format_string<T...> fmt, T&&... args)
{fmt} only supports insertion operators that are defined in the same namespaces
as the types they format and can be found with the argument-dependent lookup.

.. doxygenfunction:: print(std::basic_ostream<Char> &os, const S &format_str, Args&&... args)

.. _printf-api:

Expand Down
1 change: 0 additions & 1 deletion doc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def build_docs(version='dev', **kwargs):
FMT_USE_RVALUE_REFERENCES=1 \
FMT_USE_USER_DEFINED_LITERALS=1 \
FMT_USE_ALIAS_TEMPLATES=1 \
FMT_USE_NONTYPE_TEMPLATE_PARAMETERS=1 \
FMT_API= \
"FMT_BEGIN_NAMESPACE=namespace fmt {{" \
"FMT_END_NAMESPACE=}}" \
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The code
format(FMT_STRING("The answer is {:d}"), "forty-two");

reports a compile-time error on compilers that support relaxed ``constexpr``.
See `here <api.html#compile-time-format-string-checks>`_ for details.
See `here <api.html#c.fmt>`_ for details.

The following code

Expand Down
35 changes: 4 additions & 31 deletions doc/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@ The available presentation types for pointers are:
Chrono Format Specifications
============================

Format specifications for chrono types and ``std::tm`` have the following
syntax:
Format specifications for chrono types have the following syntax:

.. productionlist:: sf
chrono_format_spec: [[`fill`]`align`][`width`]["." `precision`][`chrono_specs`]
Expand Down Expand Up @@ -349,35 +348,9 @@ points are:
Specifiers that have a calendaric component such as `'d'` (the day of month)
are valid only for ``std::tm`` and not durations or time points.

.. range-specs:
Range Format Specifications
===========================

Format specifications for range types have the following syntax:

..productionlist:: sf
range_format_spec: [":" [`underlying_spec`]]

The `underlying_spec` is parsed based on the formatter of the range's
reference type.

By default, a range of characters or strings is printed escaped and quoted. But
if any `underlying_spec` is provided (even if it is empty), then the characters
or strings are printed according to the provided specification.

Examples:

fmt::format("{}", std::vector{10, 20, 30});
// Result: [10, 20, 30]
fmt::format("{::#x}", std::vector{10, 20, 30});
// Result: [0xa, 0x14, 0x13]
fmt::format("{}", vector{'h', 'e', 'l', 'l', 'o'});
// Result: ['h', 'e', 'l', 'l', 'o']
fmt::format("{::}", vector{'h', 'e', 'l', 'l', 'o'});
// Result: [h, e, l, l, o]
fmt::format("{::d}", vector{'h', 'e', 'l', 'l', 'o'});
// Result: [104, 101, 108, 108, 111]
``std::tm`` uses the system's `strftime
<https://en.cppreference.com/w/cpp/chrono/c/strftime>`_ so refer to its
documentation for details on supported conversion specifiers.

.. _formatexamples:

Expand Down
8 changes: 4 additions & 4 deletions include/fmt/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ class dynamic_format_arg_store
};

template <typename T>
using stored_type = conditional_t<
std::is_convertible<T, std::basic_string<char_type>>::value &&
!detail::is_reference_wrapper<T>::value,
std::basic_string<char_type>, T>;
using stored_type = conditional_t<detail::is_string<T>::value &&
!has_formatter<T, Context>::value &&
!detail::is_reference_wrapper<T>::value,
std::basic_string<char_type>, T>;

// Storage of basic_format_arg must be contiguous.
std::vector<basic_format_arg<Context>> data_;
Expand Down
Loading

0 comments on commit 29eb8e8

Please sign in to comment.