Skip to content

Commit 5502d2c

Browse files
burblebeetkoeppe
authored andcommitted
LWG3631 basic_format_arg(T&&) should use remove_cvref_t<T> throughout
[format.arg] Changed declartion of basic_format_arg::handle's ctor in class to match change in itemdecl.
1 parent 87062d5 commit 5502d2c

File tree

1 file changed

+59
-144
lines changed

1 file changed

+59
-144
lines changed

source/utilities.tex

Lines changed: 59 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -15744,17 +15744,20 @@
1574415744
\tcode{\libconcept{output_iterator}<const charT\&>}\iref{iterator.concept.output}.
1574515745

1574615746
\begin{codeblock}
15747+
template<class T, class Context,
15748+
class Formatter = typename Context::template formatter_type<remove_const_t<T>>>
15749+
concept @\defexposconcept{formattable-with}@ = // \expos
15750+
@\libconcept{semiregular}@<Formatter> &&
15751+
requires(Formatter& f, const Formatter& cf, T&& t, Context fc,
15752+
basic_format_parse_context<typename Context::char_type> pc)
15753+
{
15754+
{ f.parse(pc) } -> @\libconcept{same_as}@<typename decltype(pc)::iterator>;
15755+
{ cf.format(t, fc) } -> @\libconcept{same_as}@<typename Context::iterator>;
15756+
};
15757+
1574715758
template<class T, class charT>
1574815759
concept @\deflibconcept{formattable}@ =
15749-
@\libconcept{semiregular}@<formatter<remove_cvref_t<T>, charT>> &&
15750-
requires(formatter<remove_cvref_t<T>, charT> f,
15751-
const formatter<remove_cvref_t<T>, charT> cf,
15752-
T t,
15753-
basic_format_context<@\placeholder{fmt-iter-for}@<charT>, charT> fc,
15754-
basic_format_parse_context<charT> pc) {
15755-
{ f.parse(pc) } -> @\libconcept{same_as}@<basic_format_parse_context<charT>::iterator>;
15756-
{ cf.format(t, fc) } -> @\libconcept{same_as}@<@\placeholder{fmt-iter-for}@<charT>>;
15757-
};
15760+
@\exposconcept{formattable-with}@<remove_reference_t<T>, basic_format_context<@\placeholder{fmt-iter-for}@<charT>>>;
1575815761
\end{codeblock}
1575915762

1576015763
\pnum
@@ -16947,24 +16950,7 @@
1694716950
const char_type*, basic_string_view<char_type>,
1694816951
const void*, handle> value; // \expos
1694916952

16950-
template<class T> explicit basic_format_arg(T&& v) noexcept; // \expos
16951-
explicit basic_format_arg(float n) noexcept; // \expos
16952-
explicit basic_format_arg(double n) noexcept; // \expos
16953-
explicit basic_format_arg(long double n) noexcept; // \expos
16954-
explicit basic_format_arg(const char_type* s); // \expos
16955-
16956-
template<class traits>
16957-
explicit basic_format_arg(
16958-
basic_string_view<char_type, traits> s) noexcept; // \expos
16959-
16960-
template<class traits, class Allocator>
16961-
explicit basic_format_arg(
16962-
const basic_string<char_type, traits, Allocator>& s) noexcept; // \expos
16963-
16964-
explicit basic_format_arg(nullptr_t) noexcept; // \expos
16965-
16966-
template<class T>
16967-
explicit basic_format_arg(T* p) noexcept; // \expos
16953+
template<class T> explicit basic_format_arg(T& v) noexcept; // \expos
1696816954

1696916955
public:
1697016956
basic_format_arg() noexcept;
@@ -16994,142 +16980,74 @@
1699416980
\end{itemdescr}
1699516981

1699616982
\begin{itemdecl}
16997-
template<class T> explicit basic_format_arg(T&& v) noexcept;
16983+
template<class T> explicit basic_format_arg(T& v) noexcept;
1699816984
\end{itemdecl}
1699916985

1700016986
\begin{itemdescr}
1700116987
\pnum
1700216988
\constraints
17003-
The template specialization
17004-
\begin{codeblock}
17005-
typename Context::template formatter_type<remove_cvref_t<T>>
17006-
\end{codeblock}
17007-
meets the \newoldconcept{BasicFormatter} requirements\iref{formatter.requirements}.
17008-
The extent to which an implementation determines that
17009-
the specialization meets the \newoldconcept{BasicFormatter} requirements
17010-
is unspecified,
17011-
except that as a minimum the expression
17012-
\begin{codeblock}
17013-
typename Context::template formatter_type<remove_cvref_t<T>>()
17014-
.format(declval<T&>(), declval<Context&>())
17015-
\end{codeblock}
17016-
shall be well-formed when treated as an unevaluated operand\iref{term.unevaluated.operand}.
16989+
\tcode{T} satisfies \tcode{\exposconcept{formattable-with}<Context>}.
16990+
16991+
\pnum
16992+
\expects
16993+
If \tcode{decay_t<T>} is \tcode{char_type*} or \tcode{const char_type*},
16994+
\tcode{static_cast<const char_\linebreak{}type*>(v)} points to a NTCTS\iref{defns.ntcts}.
1701716995

1701816996
\pnum
1701916997
\effects
16998+
Let \tcode{TD} be \tcode{remove_const_t<T>}.
1702016999
\begin{itemize}
1702117000
\item
17022-
if \tcode{T} is \tcode{bool} or \tcode{char_type},
17001+
If \tcode{TD} is \tcode{bool} or \tcode{char_type},
1702317002
initializes \tcode{value} with \tcode{v};
1702417003
\item
17025-
otherwise, if \tcode{T} is \tcode{char} and \tcode{char_type} is
17004+
otherwise, if \tcode{TD} is \tcode{char} and \tcode{char_type} is
1702617005
\keyword{wchar_t}, initializes \tcode{value} with
1702717006
\tcode{static_cast<wchar_t>(v)};
1702817007
\item
17029-
otherwise, if \tcode{T} is a signed integer type\iref{basic.fundamental}
17030-
and \tcode{sizeof(T) <= sizeof(int)},
17008+
otherwise, if \tcode{TD} is a signed integer type\iref{basic.fundamental}
17009+
and \tcode{sizeof(TD) <= sizeof(int)},
1703117010
initializes \tcode{value} with \tcode{static_cast<int>(v)};
1703217011
\item
17033-
otherwise, if \tcode{T} is an unsigned integer type and
17034-
\tcode{sizeof(T) <= sizeof(unsigned int)}, initializes
17012+
otherwise, if \tcode{TD} is an unsigned integer type and
17013+
\tcode{sizeof(TD) <= sizeof(unsigned int)}, initializes
1703517014
\tcode{value} with \tcode{static_cast<unsigned int>(v)};
1703617015
\item
17037-
otherwise, if \tcode{T} is a signed integer type and
17038-
\tcode{sizeof(T) <= sizeof(long long int)}, initializes
17016+
otherwise, if \tcode{TD} is a signed integer type and
17017+
\tcode{sizeof(TD) <= sizeof(long long int)}, initializes
1703917018
\tcode{value} with \tcode{static_cast<long long int>(v)};
1704017019
\item
17041-
otherwise, if \tcode{T} is an unsigned integer type and
17042-
\tcode{sizeof(T) <= sizeof(unsigned long long int)}, initializes
17020+
otherwise, if \tcode{TD} is an unsigned integer type and
17021+
\tcode{sizeof(TD) <= sizeof(unsigned long long int)}, initializes
1704317022
\tcode{value} with
1704417023
\tcode{static_cast<unsigned long long int>(v)};
1704517024
\item
17025+
otherwise, if \tcode{TD} is a standard floating-point type,
17026+
initializes \tcode{value} with \tcode{v};
17027+
\item
17028+
otherwise, if \tcode{TD} is
17029+
a specialization of \tcode{basic_string_view} or \tcode{basic_string} and
17030+
\tcode{TD::value_type} is \tcode{char_type},
17031+
initializes \tcode{value} with
17032+
\tcode{basic_string_view<char_type>(v.data(), v.size())};
17033+
\item
17034+
otherwise, if \tcode{decay_t<TD>} is
17035+
\tcode{char_type*} or \tcode{const char_type*},
17036+
initializes \tcode{value} with \tcode{static_cast<const char_type*>(v)};
17037+
\item
17038+
otherwise, if \tcode{is_void_v<remove_pointer_t<TD>>} is \tcode{true} or
17039+
\tcode{is_null_pointer_v<TD>} is \tcode{true},
17040+
initializes \tcode{value} with \tcode{static_cast<const void*>(v)};
17041+
\item
1704617042
otherwise, initializes \tcode{value} with \tcode{handle(v)}.
1704717043
\end{itemize}
17048-
\end{itemdescr}
17049-
17050-
\begin{itemdecl}
17051-
explicit basic_format_arg(float n) noexcept;
17052-
explicit basic_format_arg(double n) noexcept;
17053-
explicit basic_format_arg(long double n) noexcept;
17054-
\end{itemdecl}
17055-
17056-
\begin{itemdescr}
17057-
\pnum
17058-
\effects
17059-
Initializes \tcode{value} with \tcode{n}.
17060-
\end{itemdescr}
17061-
17062-
\begin{itemdecl}
17063-
explicit basic_format_arg(const char_type* s);
17064-
\end{itemdecl}
17065-
17066-
\begin{itemdescr}
17067-
\pnum
17068-
\expects
17069-
\tcode{s} points to a NTCTS\iref{defns.ntcts}.
17070-
17071-
\pnum
17072-
\effects
17073-
Initializes \tcode{value} with \tcode{s}.
17074-
\end{itemdescr}
17075-
17076-
\begin{itemdecl}
17077-
template<class traits>
17078-
explicit basic_format_arg(basic_string_view<char_type, traits> s) noexcept;
17079-
\end{itemdecl}
17080-
17081-
\begin{itemdescr}
17082-
\pnum
17083-
\effects
17084-
Initializes \tcode{value} with
17085-
\tcode{basic_string_view<char_type>(s.data(), s.size())}.
17086-
\end{itemdescr}
17087-
17088-
\begin{itemdecl}
17089-
template<class traits, class Allocator>
17090-
explicit basic_format_arg(
17091-
const basic_string<char_type, traits, Allocator>& s) noexcept;
17092-
\end{itemdecl}
17093-
17094-
\begin{itemdescr}
17095-
\pnum
17096-
\effects
17097-
Initializes \tcode{value} with
17098-
\tcode{basic_string_view<char_type>(s.data(), s.size())}.
17099-
\end{itemdescr}
17100-
17101-
\begin{itemdecl}
17102-
explicit basic_format_arg(nullptr_t) noexcept;
17103-
\end{itemdecl}
17104-
17105-
\begin{itemdescr}
17106-
\pnum
17107-
\effects
17108-
Initializes \tcode{value} with
17109-
\tcode{static_cast<const void*>(nullptr)}.
17110-
\end{itemdescr}
17111-
17112-
\begin{itemdecl}
17113-
template<class T> explicit basic_format_arg(T* p) noexcept;
17114-
\end{itemdecl}
17115-
17116-
\begin{itemdescr}
17117-
\pnum
17118-
\constraints
17119-
\tcode{is_void_v<T>} is \tcode{true}.
17120-
17121-
\pnum
17122-
\effects
17123-
Initializes \tcode{value} with \tcode{p}.
17124-
17125-
\pnum
1712617044
\begin{note}
17127-
Constructing \tcode{basic_format_arg} from
17128-
a pointer to a member is ill-formed unless
17129-
the user provides an enabled specialization of
17130-
\tcode{formatter} for that pointer to member type.
17045+
Constructing \tcode{basic_format_arg} from a pointer to a member is ill-formed
17046+
unless the user provides an enabled specialization of \tcode{formatter}
17047+
for that pointer to member type.
1713117048
\end{note}
1713217049
\end{itemdescr}
17050+
1713317051
\indexlibrary{\idxcode{basic_format_arg}!constructor|)}%
1713417052

1713517053
\indexlibrarymember{operator bool}{basic_format_arg}%
@@ -17156,7 +17074,7 @@
1715617074
void (*format_)(basic_format_parse_context<char_type>&,
1715717075
Context&, const void*); // \expos
1715817076

17159-
template<class T> explicit handle(T&& val) noexcept; // \expos
17077+
template<class T> explicit handle(T& val) noexcept; // \expos
1716017078

1716117079
friend class basic_format_arg<Context>; // \expos
1716217080

@@ -17168,27 +17086,24 @@
1716817086

1716917087
\indexlibraryctor{basic_format_arg::handle}%
1717017088
\begin{itemdecl}
17171-
template<class T> explicit handle(T&& val) noexcept;
17089+
template<class T> explicit handle(T& val) noexcept;
1717217090
\end{itemdecl}
1717317091

1717417092
\begin{itemdescr}
1717517093
\pnum
1717617094
Let
1717717095
\begin{itemize}
1717817096
\item
17179-
\tcode{TD} be \tcode{remove_cvref_t<T>},
17180-
\item
17181-
\exposid{const-formattable} be \tcode{true} if
17182-
\tcode{typename Context::template formatter_type<TD>()\newline .format(declval<const TD\&>(), declval<Context\&>())} is well-formed, otherwise \tcode{false},
17097+
\tcode{TD} be \tcode{remove_const_t<T>},
1718317098
\item
17184-
\tcode{TQ} be \tcode{const TD} if \exposid{const-formattable} is \tcode{true}
17099+
\tcode{TQ} be \tcode{const TD} if
17100+
\tcode{const TD} satisfies \tcode{\exposconcept{formattable-with}<Context>}
1718517101
and \tcode{TD} otherwise.
1718617102
\end{itemize}
1718717103

1718817104
\pnum
1718917105
\mandates
17190-
\tcode{\exposid{const-formattable} || !is_const_v<remove_reference_t<T>>} is
17191-
\tcode{true}.
17106+
\tcode{TQ} satisfies \tcode{\exposconcept{formattable-with}<Context>}.
1719217107

1719317108
\pnum
1719417109
\effects
@@ -17253,7 +17168,7 @@
1725317168
\pnum
1725417169
\expects
1725517170
The type
17256-
\tcode{typename Context::template formatter_type<}$\tcode{T}_i$\tcode{>}
17171+
\tcode{typename Context::template formatter_type<remove_cvref_t<}$\tcode{T}_i$\tcode{>>}\linebreak{}
1725717172
meets the \newoldconcept{BasicFormatter} requirements\iref{formatter.requirements}
1725817173
for each $\tcode{T}_i$ in \tcode{Args}.
1725917174

0 commit comments

Comments
 (0)