Skip to content

Commit 2e819a1

Browse files
authored
Some documentation improvements (#4631)
1 parent 7bce225 commit 2e819a1

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

doc/api.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,6 @@ parameterized version.
321321
322322
::: arg(const Char*, const T&)
323323
324-
Named arguments are not supported in compile-time checks at the moment.
325-
326324
### Compatibility
327325
328326
::: basic_string_view

include/fmt/base.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2310,7 +2310,7 @@ template <typename Context> class value {
23102310
template <typename T, FMT_ENABLE_IF(!has_formatter<T, char_type>())>
23112311
FMT_CONSTEXPR value(const T&, custom_tag) {
23122312
// Cannot format an argument; to make type T formattable provide a
2313-
// formatter<T> specialization: https://fmt.dev/latest/api.html#udt.
2313+
// formatter<T> specialization: https://fmt.dev/latest/api#udt.
23142314
type_is_unformattable_for<T, char_type> _;
23152315
}
23162316

@@ -2847,6 +2847,10 @@ using vargs =
28472847
* **Example**:
28482848
*
28492849
* fmt::print("The answer is {answer}.", fmt::arg("answer", 42));
2850+
*
2851+
* Named arguments passed with `fmt::arg` are not supported
2852+
* in compile-time checks, but `"answer"_a=42` are compile-time checked in
2853+
* sufficiently new compilers. See `operator""_a()`.
28502854
*/
28512855
template <typename Char, typename T>
28522856
inline auto arg(const Char* name, const T& arg) -> detail::named_arg<Char, T> {

include/fmt/format.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4147,6 +4147,14 @@ template <typename T, typename Char = char> struct nested_formatter {
41474147

41484148
inline namespace literals {
41494149
#if FMT_USE_NONTYPE_TEMPLATE_ARGS
4150+
/**
4151+
* User-defined literal equivalent of `fmt::arg`, but with compile-time checks.
4152+
*
4153+
* **Example**:
4154+
*
4155+
* using namespace fmt::literals;
4156+
* fmt::print("The answer is {answer}.", "answer"_a=42);
4157+
*/
41504158
template <detail::fixed_string S> constexpr auto operator""_a() {
41514159
using char_t = remove_cvref_t<decltype(*S.data)>;
41524160
return detail::udl_arg<char_t, sizeof(S.data) / sizeof(char_t), S>();

0 commit comments

Comments
 (0)