Skip to content

Commit 3e737c3

Browse files
authored
Merge 2023-06 LWG Motion 20
P2757R3 Type checking format args
2 parents ae15824 + 60f7296 commit 3e737c3

File tree

2 files changed

+80
-9
lines changed

2 files changed

+80
-9
lines changed

source/support.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@
628628
#define @\defnlibxname{cpp_lib_filesystem}@ 201703L // also in \libheader{filesystem}
629629
#define @\defnlibxname{cpp_lib_flat_map}@ 202207L // also in \libheader{flat_map}
630630
#define @\defnlibxname{cpp_lib_flat_set}@ 202207L // also in \libheader{flat_set}
631-
#define @\defnlibxname{cpp_lib_format}@ 202304L // also in \libheader{format}
631+
#define @\defnlibxname{cpp_lib_format}@ 202305L // also in \libheader{format}
632632
#define @\defnlibxname{cpp_lib_format_ranges}@ 202207L // also in \libheader{format}
633633
#define @\defnlibxname{cpp_lib_formatters}@ 202302L // also in \libheader{stacktrace}, \libheader{thread}
634634
#define @\defnlibxname{cpp_lib_forward_like}@ 202207L // freestanding, also in \libheader{utility}

source/utilities.tex

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15442,9 +15442,9 @@
1544215442
If \tcode{\{ \opt{\fmtgrammarterm{arg-id}} \}} is used in
1544315443
a \fmtgrammarterm{width} or \fmtgrammarterm{precision} option,
1544415444
the value of the corresponding formatting argument is used as the value of the option.
15445-
If the corresponding formatting argument is
15446-
not of standard signed or unsigned integer type, or
15447-
its value is negative,
15445+
The option is valid only if the corresponding formatting argument is
15446+
of standard signed or unsigned integer type.
15447+
If its value is negative,
1544815448
an exception of type \tcode{format_error} is thrown.
1544915449

1545015450
\pnum
@@ -16555,8 +16555,7 @@
1655516555
size_t num_args_; // \expos
1655616556

1655716557
public:
16558-
constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt,
16559-
size_t num_args = 0) noexcept;
16558+
constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt) noexcept;
1656016559
basic_format_parse_context(const basic_format_parse_context&) = delete;
1656116560
basic_format_parse_context& operator=(const basic_format_parse_context&) = delete;
1656216561

@@ -16566,6 +16565,11 @@
1656616565

1656716566
constexpr size_t next_arg_id();
1656816567
constexpr void check_arg_id(size_t id);
16568+
16569+
template<class... Ts>
16570+
constexpr void check_dynamic_spec(size_t id) noexcept;
16571+
constexpr void check_dynamic_spec_integral(size_t id) noexcept;
16572+
constexpr void check_dynamic_spec_string(size_t id) noexcept;
1656916573
};
1657016574
}
1657116575
\end{codeblock}
@@ -16578,8 +16582,7 @@
1657816582

1657916583
\indexlibraryctor{basic_format_parse_context}%
1658016584
\begin{itemdecl}
16581-
constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt,
16582-
size_t num_args = 0) noexcept;
16585+
constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt) noexcept;
1658316586
\end{itemdecl}
1658416587

1658516588
\begin{itemdescr}
@@ -16590,7 +16593,13 @@
1659016593
\tcode{end_} with \tcode{fmt.end()},
1659116594
\tcode{indexing_} with \tcode{unknown},
1659216595
\tcode{next_arg_id_} with \tcode{0}, and
16593-
\tcode{num_args_} with \tcode{num_args}.
16596+
\tcode{num_args_} with \tcode{0}.
16597+
\begin{note}
16598+
Any call to
16599+
\tcode{next_arg_id}, \tcode{check_arg_id}, or \tcode{check_dynamic_spec}
16600+
on an instance of \tcode{basic_format_parse_context}
16601+
initialized using this constructor is not a core constant expression.
16602+
\end{note}
1659416603
\end{itemdescr}
1659516604

1659616605
\indexlibrarymember{begin}{basic_format_parse_context}%
@@ -16683,6 +16692,68 @@
1668316692
core constant expressions\iref{expr.const}.
1668416693
\end{itemdescr}
1668516694

16695+
\indexlibrarymember{check_dynamic_spec}{basic_format_parse_context}%
16696+
\begin{itemdecl}
16697+
template<class... Ts>
16698+
constexpr void check_dynamic_spec(size_t id) noexcept;
16699+
\end{itemdecl}
16700+
16701+
\begin{itemdescr}
16702+
\pnum
16703+
\mandates
16704+
The types in \tcode{Ts...} are unique.
16705+
Each type in \tcode{Ts...} is one of
16706+
\keyword{bool},
16707+
\tcode{char_type},
16708+
\keyword{int},
16709+
\tcode{\keyword{unsigned} \keyword{int}},
16710+
\tcode{\keyword{long} \keyword{long} \keyword{int}},
16711+
\tcode{\keyword{unsigned} \keyword{long} \keyword{long} \keyword{int}},
16712+
\keyword{float},
16713+
\keyword{double},
16714+
\tcode{\keyword{long} \keyword{double}},
16715+
\tcode{\keyword{const} char_type*},
16716+
\tcode{basic_string_view<char_type>}, or
16717+
\tcode{\keyword{const} \keyword{void}*}.
16718+
16719+
\pnum
16720+
\remarks
16721+
Call expressions where
16722+
\tcode{id >= num_args_} or
16723+
the type of the corresponding format argument
16724+
(after conversion to \tcode{basic_format_arg<Context>})
16725+
is not one of the types in \tcode{Ts...}
16726+
are not core constant expressions\iref{expr.const}.
16727+
\end{itemdescr}
16728+
16729+
\indexlibrarymember{check_dynamic_spec_integral}{basic_format_parse_context}%
16730+
\begin{itemdecl}
16731+
constexpr void check_dynamic_spec_integral(size_t id) noexcept;
16732+
\end{itemdecl}
16733+
16734+
\begin{itemdescr}
16735+
\pnum
16736+
\effects
16737+
Equivalent to:
16738+
\begin{codeblock}
16739+
check_dynamic_spec<int, unsigned int, long long int, unsigned long long int>(id);
16740+
\end{codeblock}
16741+
\end{itemdescr}
16742+
16743+
\indexlibrarymember{check_dynamic_spec_string}{basic_format_parse_context}%
16744+
\begin{itemdecl}
16745+
constexpr void check_dynamic_spec_string(size_t id) noexcept;
16746+
\end{itemdecl}
16747+
16748+
\begin{itemdescr}
16749+
\pnum
16750+
\effects
16751+
Equivalent to:
16752+
\begin{codeblock}
16753+
check_dynamic_spec<const char_type*, basic_string_view<char_type>>(id);
16754+
\end{codeblock}
16755+
\end{itemdescr}
16756+
1668616757
\rSec3[format.context]{Class template \tcode{basic_format_context}}
1668716758

1668816759
\indexlibraryglobal{basic_format_context}%

0 commit comments

Comments
 (0)