mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 21:16:56 +00:00
Fix docs
This commit is contained in:
parent
8c2557710d
commit
728e4f5a8d
@ -63,6 +63,16 @@
|
|||||||
std::vector<char> out;
|
std::vector<char> out;
|
||||||
fmt::format_to(std::back_inserter(out), "{}", 42);
|
fmt::format_to(std::back_inserter(out), "{}", 42);
|
||||||
|
|
||||||
|
* Added the `formatted_size
|
||||||
|
<http://fmtlib.net/dev/api.html#output-iterator-support>`_ function for
|
||||||
|
computing output size:
|
||||||
|
|
||||||
|
.. code:: c++
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
|
auto size = fmt::formatted_size("{}", 12345); // size == 5
|
||||||
|
|
||||||
* Improved compile times by reducing dependencies on standard headers and
|
* Improved compile times by reducing dependencies on standard headers and
|
||||||
providing a lightweight `core API <http://fmtlib.net/dev/api.html#core-api>`_:
|
providing a lightweight `core API <http://fmtlib.net/dev/api.html#core-api>`_:
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ The following user-defined literals are defined in ``fmt/format.h``.
|
|||||||
Utilities
|
Utilities
|
||||||
---------
|
---------
|
||||||
|
|
||||||
.. dosygenfunction:: fmt::formatted_size(string_view, const Args&...)
|
.. doxygenfunction:: fmt::formatted_size(string_view, const Args&...)
|
||||||
|
|
||||||
.. doxygenfunction:: fmt::to_string(const T&)
|
.. doxygenfunction:: fmt::to_string(const T&)
|
||||||
|
|
||||||
|
@ -193,13 +193,11 @@ typename std::add_rvalue_reference<T>::type declval() FMT_NOEXCEPT;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
|
||||||
An implementation of ``std::basic_string_view`` for pre-C++17. It provides a
|
An implementation of ``std::basic_string_view`` for pre-C++17. It provides a
|
||||||
subset of the API. ``fmt::basic_string_view`` is used for format strings even
|
subset of the API. ``fmt::basic_string_view`` is used for format strings even
|
||||||
if ``std::string_view`` is available to prevent issues when a library is
|
if ``std::string_view`` is available to prevent issues when a library is
|
||||||
compiled with a different ``-std`` option than the client code (which is not
|
compiled with a different ``-std`` option than the client code (which is not
|
||||||
recommended).
|
recommended).
|
||||||
\endrst
|
|
||||||
*/
|
*/
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
class basic_string_view {
|
class basic_string_view {
|
||||||
@ -238,11 +236,7 @@ class basic_string_view {
|
|||||||
basic_string_view(const Char *s)
|
basic_string_view(const Char *s)
|
||||||
: data_(s), size_(std::char_traits<Char>::length(s)) {}
|
: data_(s), size_(std::char_traits<Char>::length(s)) {}
|
||||||
|
|
||||||
/**
|
/** Constructs a string reference from a ``std::basic_string`` object. */
|
||||||
\rst
|
|
||||||
Constructs a string reference from a ``std::basic_string`` object.
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename Alloc>
|
template <typename Alloc>
|
||||||
FMT_CONSTEXPR basic_string_view(
|
FMT_CONSTEXPR basic_string_view(
|
||||||
const std::basic_string<Char, Alloc> &s) FMT_NOEXCEPT
|
const std::basic_string<Char, Alloc> &s) FMT_NOEXCEPT
|
||||||
@ -329,11 +323,7 @@ class basic_buffer {
|
|||||||
capacity_ = capacity;
|
capacity_ = capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Increases the buffer capacity to hold at least *capacity* elements. */
|
||||||
\rst
|
|
||||||
Increases the buffer capacity to hold at least *capacity* elements.
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
virtual void grow(std::size_t capacity) = 0;
|
virtual void grow(std::size_t capacity) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -365,11 +355,7 @@ class basic_buffer {
|
|||||||
size_ = new_size;
|
size_ = new_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Reserves space to store at least *capacity* elements. */
|
||||||
\rst
|
|
||||||
Reserves space to store at least *capacity* elements.
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
void reserve(std::size_t capacity) {
|
void reserve(std::size_t capacity) {
|
||||||
if (capacity > capacity_)
|
if (capacity > capacity_)
|
||||||
grow(capacity);
|
grow(capacity);
|
||||||
@ -899,10 +885,8 @@ class basic_format_context :
|
|||||||
using typename base::iterator;
|
using typename base::iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
|
||||||
Constructs a ``basic_format_context`` object. References to the arguments are
|
Constructs a ``basic_format_context`` object. References to the arguments are
|
||||||
stored in the object so make sure they have appropriate lifetimes.
|
stored in the object so make sure they have appropriate lifetimes.
|
||||||
\endrst
|
|
||||||
*/
|
*/
|
||||||
basic_format_context(OutputIt out, basic_string_view<char_type> format_str,
|
basic_format_context(OutputIt out, basic_string_view<char_type> format_str,
|
||||||
basic_format_args<basic_format_context> args)
|
basic_format_args<basic_format_context> args)
|
||||||
|
@ -3391,9 +3391,7 @@ std::string to_string(const T &value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
|
||||||
Converts *value* to ``std::wstring`` using the default format for type *T*.
|
Converts *value* to ``std::wstring`` using the default format for type *T*.
|
||||||
\endrst
|
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::wstring to_wstring(const T &value) {
|
std::wstring to_wstring(const T &value) {
|
||||||
@ -3535,7 +3533,10 @@ inline typename std::enable_if<internal::is_format_string<String>::value>::type
|
|||||||
return vprint(format_str.data(), make_format_args(args...));
|
return vprint(format_str.data(), make_format_args(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Counts the number of characters in the output of format(format_str, args...).
|
/**
|
||||||
|
Returns the number of characters in the output of
|
||||||
|
``format(format_str, args...)``.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline std::size_t formatted_size(string_view format_str,
|
inline std::size_t formatted_size(string_view format_str,
|
||||||
const Args & ... args) {
|
const Args & ... args) {
|
||||||
|
Loading…
Reference in New Issue
Block a user