diff --git a/include/fmt/base.h b/include/fmt/base.h index 5be5c062..4fa3cc1c 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -512,15 +512,13 @@ template class basic_string_view { constexpr basic_string_view() noexcept : data_(nullptr), size_(0) {} - /** Constructs a string reference object from a C string and a size. */ + /// Constructs a string reference object from a C string and a size. constexpr basic_string_view(const Char* s, size_t count) noexcept : data_(s), size_(count) {} constexpr basic_string_view(std::nullptr_t) = delete; - /** - Constructs a string reference object from a C string. - */ + /// Constructs a string reference object from a C string. FMT_CONSTEXPR20 basic_string_view(const Char* s) : data_(s), @@ -539,10 +537,10 @@ template class basic_string_view { FMT_CONSTEXPR basic_string_view(const S& s) noexcept : data_(s.data()), size_(s.size()) {} - /** Returns a pointer to the string data. */ + /// Returns a pointer to the string data. constexpr auto data() const noexcept -> const Char* { return data_; } - /** Returns the string size. */ + /// Returns the string size. constexpr auto size() const noexcept -> size_t { return size_; } constexpr auto begin() const noexcept -> iterator { return data_; } @@ -601,7 +599,7 @@ template class basic_string_view { FMT_EXPORT using string_view = basic_string_view; -/** Specifies if ``T`` is a character type. Can be specialized by users. */ +/// Specifies if ``T`` is a character type. Can be specialized by users. FMT_EXPORT template struct is_char : std::false_type {}; template <> struct is_char : std::true_type {}; @@ -731,17 +729,15 @@ FMT_DEPRECATED FMT_NORETURN inline void throw_format_error( report_error(message); } -/** String's character (code unit) type. */ +/// String's character (code unit) type. template ()))> using char_t = typename V::value_type; /** - \rst - Parsing context consisting of a format string range being parsed and an + A parsing context consisting of a format string range being parsed and an argument counter for automatic indexing. - You can use the ``format_parse_context`` type alias for ``char`` instead. - \endrst + You can use the `format_parse_context` type alias for `char` instead. */ FMT_EXPORT template class basic_format_parse_context { @@ -767,12 +763,10 @@ template class basic_format_parse_context { return format_str_.begin(); } - /** - Returns an iterator past the end of the format string range being parsed. - */ + /// Returns an iterator past the end of the format string range being parsed. constexpr auto end() const noexcept -> iterator { return format_str_.end(); } - /** Advances the begin iterator to ``it``. */ + /// Advances the begin iterator to `it`. FMT_CONSTEXPR void advance_to(iterator it) { format_str_.remove_prefix(detail::to_unsigned(it - begin())); } @@ -850,10 +844,8 @@ class compile_parse_context : public basic_format_parse_context { }; /** - \rst A contiguous memory buffer with an optional growing ability. It is an internal - class and shouldn't be used directly, only via `~fmt::basic_memory_buffer`. - \endrst + class and shouldn't be used directly, only via `basic_memory_buffer`. */ template class buffer { private: @@ -877,7 +869,7 @@ template class buffer { FMT_CONSTEXPR20 ~buffer() = default; buffer(buffer&&) = default; - /** Sets the buffer data and capacity. */ + /// Sets the buffer data and capacity. FMT_CONSTEXPR void set(T* buf_data, size_t buf_capacity) noexcept { ptr_ = buf_data; capacity_ = buf_capacity; @@ -896,17 +888,17 @@ template class buffer { auto begin() const noexcept -> const T* { return ptr_; } auto end() const noexcept -> const T* { return ptr_ + size_; } - /** Returns the size of this buffer. */ + /// Returns the size of this buffer. constexpr auto size() const noexcept -> size_t { return size_; } - /** Returns the capacity of this buffer. */ + /// Returns the capacity of this buffer. constexpr auto capacity() const noexcept -> size_t { return capacity_; } - /** Returns a pointer to the buffer data (not null-terminated). */ + /// Returns a pointer to the buffer data (not null-terminated). FMT_CONSTEXPR auto data() noexcept -> T* { return ptr_; } FMT_CONSTEXPR auto data() const noexcept -> const T* { return ptr_; } - /** Clears this buffer. */ + /// Clears this buffer. void clear() { size_ = 0; } // Tries resizing the buffer to contain *count* elements. If T is a POD type @@ -929,7 +921,7 @@ template class buffer { ptr_[size_++] = value; } - /** Appends data to the end of the buffer. */ + /// Appends data to the end of the buffer. template void append(const U* begin, const U* end) { while (begin != end) { auto count = to_unsigned(end - begin); @@ -1772,12 +1764,10 @@ template class basic_format_arg { } /** - \rst Visits an argument dispatching to the appropriate visit method based on - the argument type. For example, if the argument type is ``double`` then - ``vis(value)`` will be called with the value of type ``double``. - \endrst - */ + the argument type. For example, if the argument type is `double` then + `vis(value)` will be called with the value of type `double`. + */ template FMT_CONSTEXPR auto visit(Visitor&& vis) -> decltype(vis(0)) { switch (type_) { @@ -1835,14 +1825,14 @@ FMT_DEPRECATED FMT_CONSTEXPR auto visit_format_arg( } /** - \rst A view of a collection of formatting arguments. To avoid lifetime issues it should only be used as a parameter type in type-erased functions such as - ``vformat``:: + `vformat`: - void vlog(string_view format_str, format_args args); // OK - format_args args = make_format_args(); // Error: dangling reference - \endrst + ```c++ + void vlog(string_view format_str, format_args args); // OK + format_args args = make_format_args(); // Error: dangling reference + ``` */ template class basic_format_args { public: @@ -1881,11 +1871,7 @@ template class basic_format_args { public: constexpr basic_format_args() : desc_(0), args_(nullptr) {} - /** - \rst - Constructs a `basic_format_args` object from `~fmt::format_arg_store`. - \endrst - */ + /// Constructs a `basic_format_args` object from `format_arg_store`. template constexpr FMT_ALWAYS_INLINE basic_format_args( @@ -1900,25 +1886,16 @@ template class basic_format_args { store) : desc_(DESC), args_(store.args + (NUM_NAMED_ARGS != 0 ? 1 : 0)) {} - /** - \rst - Constructs a `basic_format_args` object from - `~fmt::dynamic_format_arg_store`. - \endrst - */ + /// Constructs a `basic_format_args` object from `dynamic_format_arg_store`. constexpr basic_format_args(const dynamic_format_arg_store& store) : desc_(store.get_types()), args_(store.data()) {} - /** - \rst - Constructs a `basic_format_args` object from a dynamic list of arguments. - \endrst - */ + /// Constructs a `basic_format_args` object from a dynamic list of arguments. constexpr basic_format_args(const format_arg* args, int count) : desc_(detail::is_unpacked_bit | detail::to_unsigned(count)), args_(args) {} - /** Returns the argument with the specified id. */ + /// Returns the argument with the specified id. FMT_CONSTEXPR auto get(int id) const -> format_arg { format_arg arg; if (!is_packed()) { @@ -1964,7 +1941,7 @@ class context { detail::locale_ref loc_; public: - /** The character type for the output. */ + /// The character type for the output. using char_type = char; using iterator = appender; @@ -2022,12 +1999,9 @@ concept formattable = is_formattable, Char>::value; #endif /** - \rst Constructs an object that stores references to arguments and can be implicitly - converted to `~fmt::format_args`. `Context` can be omitted in which case it - defaults to `~fmt::format_context`. See `~fmt::arg` for lifetime - considerations. - \endrst + converted to `format_args`. `Context` can be omitted in which case it defaults + to `format_context`. See `arg` for lifetime considerations. */ // Take arguments by lvalue references to avoid some lifetime issues, e.g. // auto args = make_format_args(std::string()); @@ -2056,7 +2030,6 @@ constexpr auto make_format_args(T&... args) #endif /** - \rst Returns a named argument to be used in a formatting function. It should only be used in a call to a formatting function or `dynamic_format_arg_store::push_back`. @@ -2064,7 +2037,6 @@ constexpr auto make_format_args(T&... args) **Example**:: fmt::print("Elapsed time: {s:.2f} seconds", fmt::arg("s", 1.23)); - \endrst */ template inline auto arg(const Char* name, const T& arg) -> detail::named_arg { @@ -2073,7 +2045,7 @@ inline auto arg(const Char* name, const T& arg) -> detail::named_arg { } FMT_END_EXPORT -/** An alias to ``basic_format_args``. */ +/// An alias to ``basic_format_args``. // A separate type would result in shorter symbols but break ABI compatibility // between clang and gcc on ARM (#1919). FMT_EXPORT using format_args = basic_format_args; @@ -2878,7 +2850,7 @@ template struct runtime_format_string { basic_string_view str; }; -/** A compile-time format string. */ +/// A compile-time format string. template class basic_format_string { private: basic_string_view str_; @@ -2933,7 +2905,7 @@ using format_string = basic_format_string...>; inline auto runtime(string_view s) -> runtime_format_string<> { return {{s}}; } #endif -/** Formats a string and writes the output to ``out``. */ +/// Formats a string and writes the output to ``out``. template , char>::value)> @@ -3039,14 +3011,13 @@ FMT_API void vprint_buffered(FILE* f, string_view fmt, format_args args); FMT_API void vprintln(FILE* f, string_view fmt, format_args args); /** - \rst - Formats ``args`` according to specifications in ``fmt`` and writes the output - to ``stdout``. - - **Example**:: - - fmt::print("Elapsed time: {0:.2f} seconds", 1.23); - \endrst + * Formats `args` according to specifications in `fmt` and writes the output + * to `stdout`. + * + * **Example**: + * ``` + * fmt::print("Elapsed time: {0:.2f} seconds", 1.23); + * ``` */ template FMT_INLINE void print(format_string fmt, T&&... args) { @@ -3057,14 +3028,12 @@ FMT_INLINE void print(format_string fmt, T&&... args) { } /** - \rst - Formats ``args`` according to specifications in ``fmt`` and writes the - output to the file ``f``. - - **Example**:: - - fmt::print(stderr, "Don't {}!", "panic"); - \endrst + * Formats `args` according to specifications in `fmt` and writes the + * output to the file `f`. + * + * **Example**: + * + * fmt::print(stderr, "Don't {}!", "panic"); */ template FMT_INLINE void print(FILE* f, format_string fmt, T&&... args) {