From df1ba52b641f0769109d0c905ce69e09a0a0aa81 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 22 Apr 2018 17:04:28 -0700 Subject: [PATCH] Update example --- README.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 2fa9b916..f412c759 100644 --- a/README.rst +++ b/README.rst @@ -97,14 +97,15 @@ Format strings can be checked at compile time: context_.on_error("argument index out of range"); ^ -{fmt} can be used as a safe portable replacement for ``itoa``: +{fmt} can be used as a safe portable replacement for ``itoa`` +(`godbolt `_): .. code:: c++ - fmt::MemoryWriter w; - w << 42; // replaces itoa(42, buffer, 10) - w << fmt::hex(42); // replaces itoa(42, buffer, 16) - // access the string using w.str() or w.c_str() + fmt::memory_buffer buf; + format_to(buf, "{}", 42); // replaces itoa(42, buffer, 10) + format_to(buf, "{:x}", 42); // replaces itoa(42, buffer, 16) + // access the string using to_string(buf) or buf.data() An object of any user-defined type for which there is an overloaded :code:`std::ostream` insertion operator (``operator<<``) can be formatted: