forked from fmtlib/fmt
expose detail::throw_format_error (#3551)
This enables to only #include <fmt/core.h> when defining formatters.
This commit is contained in:
@@ -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.
|
template for your type and implement ``parse`` and ``format`` methods.
|
||||||
For example::
|
For example::
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
struct point {
|
struct point {
|
||||||
double x, y;
|
double x, y;
|
||||||
@@ -156,7 +156,7 @@ For example::
|
|||||||
if (it != end && (*it == 'f' || *it == 'e')) presentation = *it++;
|
if (it != end && (*it == 'f' || *it == 'e')) presentation = *it++;
|
||||||
|
|
||||||
// Check if reached the end of the range:
|
// 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 an iterator past the end of the parsed range:
|
||||||
return it;
|
return it;
|
||||||
|
@@ -638,6 +638,9 @@ struct error_handler {
|
|||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
/** Helper function to throw an error from a custom formatter. */
|
||||||
|
using detail::throw_format_error;
|
||||||
|
|
||||||
/** String's character type. */
|
/** String's character type. */
|
||||||
template <typename S> using char_t = typename detail::char_t_impl<S>::type;
|
template <typename S> using char_t = typename detail::char_t_impl<S>::type;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user