From b4bc860631169d8c8fbdcb97a155ded0f8664d93 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 3 Dec 2018 13:46:56 +0000 Subject: [PATCH 1/6] [meta.logical] Change j > i to more precise i < j <= N --- source/meta.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/meta.tex b/source/meta.tex index 6c6d7914fd..9fa169c4a4 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -2188,7 +2188,7 @@ if there is a template type argument $\tcode{B}_{i}$ for which \tcode{bool($\tcode{B}_{i}$::value)} is \tcode{false}, then instantiating \tcode{conjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>::value} -does not require the instantiation of \tcode{$\tcode{B}_{j}$::value} for $j > i$. +does not require the instantiation of \tcode{$\tcode{B}_{j}$::value} for $i < j \leq N$. \begin{note} This is analogous to the short-circuiting behavior of the built-in operator \tcode{\&\&}. @@ -2240,7 +2240,7 @@ if there is a template type argument $\tcode{B}_{i}$ for which \tcode{bool($\tcode{B}_{i}$::value)} is \tcode{true}, then instantiating \tcode{disjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>::value} -does not require the instantiation of \tcode{$\tcode{B}_{j}$::value} for $j > i$. +does not require the instantiation of \tcode{$\tcode{B}_{j}$::value} for $i < j \leq N$. \begin{note} This is analogous to the short-circuiting behavior of the built-in operator \tcode{||}. From 7b949257bc6da4e1b397b5743bfb0b82017d7e6b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 3 Dec 2018 14:31:56 +0000 Subject: [PATCH 2/6] [meta.logical] Replace "the instantiation of Bj::value" The type Bj might not be a template, so it doesn't make sense to talk about instantiation. Use wording similar to that in [temp.inst] p3 which specifies when a member of a template is implicitly instantiated. --- source/meta.tex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/meta.tex b/source/meta.tex index 9fa169c4a4..a6202a5139 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -2188,7 +2188,8 @@ if there is a template type argument $\tcode{B}_{i}$ for which \tcode{bool($\tcode{B}_{i}$::value)} is \tcode{false}, then instantiating \tcode{conjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>::value} -does not require the instantiation of \tcode{$\tcode{B}_{j}$::value} for $i < j \leq N$. +does not require a definition of \tcode{$\tcode{B}_{j}$::value} +to exist\iref{temp.inst} for $i < j \leq N$. \begin{note} This is analogous to the short-circuiting behavior of the built-in operator \tcode{\&\&}. @@ -2240,7 +2241,8 @@ if there is a template type argument $\tcode{B}_{i}$ for which \tcode{bool($\tcode{B}_{i}$::value)} is \tcode{true}, then instantiating \tcode{disjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>::value} -does not require the instantiation of \tcode{$\tcode{B}_{j}$::value} for $i < j \leq N$. +does not require a definition of \tcode{$\tcode{B}_{j}$::value} +to exist\iref{temp.inst} for $i < j \leq N$. \begin{note} This is analogous to the short-circuiting behavior of the built-in operator \tcode{||}. From 263f931193843ed705cf12b8ba49cbcc509ebd9d Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 3 Dec 2018 16:06:28 +0000 Subject: [PATCH 3/6] [meta.logical] Add example of short-circuiting --- source/meta.tex | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/meta.tex b/source/meta.tex index a6202a5139..3b71a60330 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -2194,6 +2194,23 @@ This is analogous to the short-circuiting behavior of the built-in operator \tcode{\&\&}. \end{note} +\begin{note} +This allows types without a \tcode{value} static data member +to be template arguments for \tcode{conjunction}, as long as an +earlier argument evaluates to \tcode{false}, for example: +\begin{codeblock} +template + concept HasValue = requires { { T::value } -> std::convertible_to; }; +template + using maybe_value = std::conjunction>, T>; + +struct X { }; + +static_assert( ! maybe_value::value ); // OK, \tcode{X::value} not used +static_assert( ! maybe_value::value ); // OK, \tcode{int::value} not used +static_assert( maybe_value::value ); +\end{codeblock} +\end{note} \pnum Every template type argument From 4500284c5044304d7668fb63c40d00389f7b6a4f Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 20 Apr 2022 11:51:30 +0100 Subject: [PATCH 4/6] proposed rewrite --- source/meta.tex | 107 ++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/source/meta.tex b/source/meta.tex index 3b71a60330..0a762e94d2 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -374,6 +374,8 @@ template struct conjunction; template struct disjunction; template struct negation; + template<> struct conjunction : true_type { }; + template<> struct disjunction : false_type { }; // \ref{meta.unary.cat}, primary type categories template @@ -2184,12 +2186,27 @@ forms the logical conjunction of its template type arguments. \pnum +For the specialization \tcode{disjunction<>}, +let $\tcode{B}_{i}$ be \tcode{true_type}. For a specialization \tcode{conjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>}, -if there is a template type argument $\tcode{B}_{i}$ -for which \tcode{bool($\tcode{B}_{i}$::value)} is \tcode{false}, -then instantiating \tcode{conjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>::value} -does not require a definition of \tcode{$\tcode{B}_{j}$::value} -to exist\iref{temp.inst} for $i < j \leq N$. +let $\tcode{B}_{i}$ be +the first type in \tcode{$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$} +for which \tcode{$\tcode{B}_{i}$::value} is \tcode{false}, +or $\tcode{B}_{N}$ if there is no such type. + +\pnum +The specialization +\tcode{conjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>} +has a public and unambiguous base class of type $\tcode{B}_{i}$. +\begin{note} +This means a specialization of \tcode{conjunction} +does not necessarily inherit from +either \tcode{true_type} or \tcode{false_type}. +\end{note} + +\pnum +Instantiation of \tcode{$\tcode{B}_{j}$::value} is required for $1 \leq j \leq i$. +Instantiation of \tcode{$\tcode{B}_{k}$::value} is not required for $i < k \leq N$. \begin{note} This is analogous to the short-circuiting behavior of the built-in operator \tcode{\&\&}. @@ -2213,33 +2230,14 @@ \end{note} \pnum -Every template type argument -for which \tcode{$\tcode{B}_{i}$::value} is instantiated +Every template type argument $\tcode{B}_{j}$ for $1 \leq j \leq i$ shall be usable as a base class and -shall have a member \tcode{value} which -is convertible to \tcode{bool}, -is not hidden, and -is unambiguously available in the type. - -\pnum -The specialization \tcode{conjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>} -has a public and unambiguous base that is either -\begin{itemize} -\item -the first type $\tcode{B}_{i}$ in the list \tcode{true_type, $\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$} -for which \tcode{bool($\tcode{B}_{i}$::value)} is \tcode{false}, or -\item -if there is no such $\tcode{B}_{i}$, the last type in the list. -\end{itemize} -\begin{note} -This means a specialization of \tcode{conjunction} -does not necessarily inherit from -either \tcode{true_type} or \tcode{false_type}. -\end{note} +shall have a member \tcode{value} such that +\tcode{bool($B_j$::value)} is a constant expression. \pnum The member names of the base class, other than \tcode{conjunction} and -\tcode{operator=}, shall not be hidden and shall be unambiguously available +\tcode{operator=}, are not hidden and are unambiguously available in \tcode{conjunction}. \end{itemdescr} @@ -2254,44 +2252,45 @@ forms the logical disjunction of its template type arguments. \pnum +For the specialization \tcode{disjunction<>}, +let $\tcode{B}_{i}$ be \tcode{false_type}. For a specialization \tcode{disjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>}, -if there is a template type argument $\tcode{B}_{i}$ -for which \tcode{bool($\tcode{B}_{i}$::value)} is \tcode{true}, -then instantiating \tcode{disjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>::value} -does not require a definition of \tcode{$\tcode{B}_{j}$::value} -to exist\iref{temp.inst} for $i < j \leq N$. -\begin{note} -This is analogous to the short-circuiting behavior of -the built-in operator \tcode{||}. -\end{note} - -\pnum -Every template type argument -for which \tcode{$\tcode{B}_{i}$::value} is instantiated -shall be usable as a base class and -shall have a member \tcode{value} which -is convertible to \tcode{bool}, -is not hidden, and -is unambiguously available in the type. +let $\tcode{B}_{i}$ be +the first type in \tcode{$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$} +for which \tcode{$\tcode{B}_{i}$::value} is \tcode{true}, +or $\tcode{B}_{N}$ if there is no such type. \pnum -The specialization \tcode{disjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>} -has a public and unambiguous base that is either -\begin{itemize} -\item the first type $\tcode{B}_{i}$ in the list \tcode{false_type, $\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$} -for which \tcode{bool($\tcode{B}_{i}$::value)} is \tcode{true}, or -\item if there is no such $\tcode{B}_{i}$, the last type in the list. -\end{itemize} +The specialization +\tcode{disjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>} +has a public and unambiguous base class of type $\tcode{B}_{i}$. \begin{note} This means a specialization of \tcode{disjunction} does not necessarily inherit from either \tcode{true_type} or \tcode{false_type}. \end{note} +\pnum +Instantiation of \tcode{$\tcode{B}_{j}$::value} is required for $1 \leq j \leq i$. +Instantiation of \tcode{$\tcode{B}_{k}$::value} is not required for $i < k \leq N$. +\begin{note} +This is analogous to the short-circuiting behavior of +the built-in operator \tcode{||}. +This allows types without a \tcode{value} static data member +to be template arguments for \tcode{disjunction}, as long as an +earlier argument evaluates to \tcode{true}, +\end{note} + +\pnum +Every template type argument $\tcode{B}_{j}$ for $1 \leq j \leq i$ +shall be usable as a base class and +shall have a member \tcode{value} such that +\tcode{bool($B_j$::value)} is a constant expression. + \pnum The member names of the base class, other than \tcode{disjunction} and \tcode{operator=}, -shall not be hidden and shall be unambiguously available in \tcode{disjunction}. +are not hidden and are unambiguously available in \tcode{disjunction}. \end{itemdescr} \indexlibraryglobal{negation}% From 0819d354b8bdc7da33bfeb8e5b5ceba077c3c425 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 20 Apr 2022 14:56:21 +0100 Subject: [PATCH 5/6] Remove whitespace in example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Johel Ernesto Guerrero Peña --- source/meta.tex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/meta.tex b/source/meta.tex index 0a762e94d2..29c106f5d7 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -2223,9 +2223,9 @@ struct X { }; -static_assert( ! maybe_value::value ); // OK, \tcode{X::value} not used -static_assert( ! maybe_value::value ); // OK, \tcode{int::value} not used -static_assert( maybe_value::value ); +static_assert(!maybe_value::value); // OK, \tcode{X::value} not used +static_assert(!maybe_value::value); // OK, \tcode{int::value} not used +static_assert(maybe_value::value); \end{codeblock} \end{note} From 603ef1a9b8511e4778715f9931afb942052e0c97 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 20 Apr 2022 14:56:54 +0100 Subject: [PATCH 6/6] Fix copy&paste error in conjunction descr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Johel Ernesto Guerrero Peña --- source/meta.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/meta.tex b/source/meta.tex index 29c106f5d7..8e06cf9718 100644 --- a/source/meta.tex +++ b/source/meta.tex @@ -2186,7 +2186,7 @@ forms the logical conjunction of its template type arguments. \pnum -For the specialization \tcode{disjunction<>}, +For the specialization \tcode{conjunction<>}, let $\tcode{B}_{i}$ be \tcode{true_type}. For a specialization \tcode{conjunction<$\tcode{B}_{1}$, $\dotsc$, $\tcode{B}_{N}$>}, let $\tcode{B}_{i}$ be