Skip to content

Commit

Permalink
expose detail::throw_format_error (#3551)
Browse files Browse the repository at this point in the history
This enables to only #include <fmt/core.h> when defining formatters.
  • Loading branch information
mjerabek authored Jul 26, 2023
1 parent 4f46cb8 commit 503d492
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ parsing and formatting. To use this method specialize the ``formatter`` struct
template for your type and implement ``parse`` and ``format`` methods.
For example::

#include <fmt/format.h>
#include <fmt/core.h>

struct point {
double x, y;
Expand Down Expand Up @@ -156,7 +156,7 @@ For example::
if (it != end && (*it == 'f' || *it == 'e')) presentation = *it++;

// Check if reached the end of the range:
if (it != end && *it != '}') throw format_error("invalid format");
if (it != end && *it != '}') throw_format_error("invalid format");

// Return an iterator past the end of the parsed range:
return it;
Expand Down
3 changes: 3 additions & 0 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,9 @@ struct error_handler {
};
} // namespace detail

/** Helper function to throw an error from a custom formatter. */
using detail::throw_format_error;

/** String's character type. */
template <typename S> using char_t = typename detail::char_t_impl<S>::type;

Expand Down

0 comments on commit 503d492

Please sign in to comment.