Skip to content

Commit e327f87

Browse files
author
Dawn Perchik
committed
P0013R1 Logical type traits
Editorially added punctuation.
1 parent be5adfb commit e327f87

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

source/utilities.tex

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9313,6 +9313,11 @@
93139313
using result_of_t = typename result_of<T>::type;
93149314
template <class...>
93159315
using void_t = void;
9316+
9317+
// \ref{meta.logical}, logical operator traits:
9318+
template<class... B> struct conjunction;
9319+
template<class... B> struct disjunction;
9320+
template<class B> struct negation;
93169321
} // namespace std
93179322
\end{codeblock}
93189323

@@ -10380,6 +10385,88 @@
1038010385
\end{codeblock}
1038110386
\exitexample
1038210387

10388+
\rSec2[meta.logical]{Logical operator traits}
10389+
10390+
\pnum
10391+
This subclause describes type traits for applying logical operators
10392+
to other type traits.
10393+
10394+
\pnum
10395+
\begin{codeblock}
10396+
template<class... B> struct conjunction : @\seebelow@ { };
10397+
\end{codeblock}
10398+
10399+
\pnum
10400+
The class template \tcode{conjunction}
10401+
forms the logical conjunction of its template type arguments.
10402+
Every template type argument
10403+
shall be usable as a base class and
10404+
shall have a member \tcode{value} which
10405+
is convertible to \tcode{bool},
10406+
is not hidden, and
10407+
is unambiguously available in the type.
10408+
10409+
\pnum
10410+
The BaseCharacteristic of a specialization \tcode{conjunction<B1, ..., BN>}
10411+
is the first type \tcode{Bi} in the list \tcode{true_type, B1, ..., BN}
10412+
for which \tcode{Bi::value == false}, or
10413+
if every \tcode{Bi::value != false}, the BaseCharacteristic is \tcode{BN}.
10414+
\enternote This means a specialization of \tcode{conjunction}
10415+
does not necessarily have a BaseCharacteristic
10416+
of either \tcode{true_type} or \tcode{false_type}.
10417+
\exitnote
10418+
10419+
\pnum
10420+
For a specialization \tcode{conjunction<B1, ..., BN>},
10421+
if there is a template type argument \tcode{Bi} with \tcode{Bi::value == false},
10422+
then instantiating \tcode{conjunction<B1, ..., BN>::value}
10423+
does not require the instantiation of \tcode{Bj::value} for \tcode{j > i}.
10424+
\enternote This is analogous to the short-circuiting behavior of \tcode{\&\&}.
10425+
\exitnote
10426+
10427+
\pnum
10428+
\begin{codeblock}
10429+
template<class... B> struct disjunction : @\seebelow@ { };
10430+
\end{codeblock}
10431+
10432+
\pnum
10433+
The class template \tcode{disjunction}
10434+
forms the logical disjunction of its template type arguments.
10435+
Every template type argument shall be usable as a base class and
10436+
shall have a member \tcode{value} which
10437+
is convertible to \tcode{bool},
10438+
is not hidden, and
10439+
is unambiguously available in the type.
10440+
10441+
\pnum
10442+
The BaseCharacteristic of a specialization \tcode{disjunction<B1, ..., BN>}
10443+
is the first type \tcode{Bi} in the list \tcode{false_type, B1, ..., BN}
10444+
for which \tcode{Bi::value != false}, or
10445+
if every \tcode{Bi::value == false}, the BaseCharacteristic is \tcode{BN}.
10446+
\enternote This means a specialization of \tcode{disjunction}
10447+
does not necessarily have a BaseCharacteristic
10448+
of either \tcode{true_type} or \tcode{false_type}.
10449+
\exitnote
10450+
10451+
\pnum
10452+
For a specialization \tcode{disjunction<B1, ..., BN>},
10453+
if there is a template type argument \tcode{Bi} with \tcode{Bi::value != false},
10454+
then instantiating \tcode{disjunction<B1, ..., BN>::value}
10455+
does not require the instantiation of \tcode{Bj::value} for \tcode{j > i}.
10456+
\enternote This is analogous to the short-circuiting behavior of \tcode{||}.
10457+
\exitnote
10458+
10459+
\pnum
10460+
\begin{codeblock}
10461+
template<class B> struct negation : bool_constant<!B::value> { };
10462+
\end{codeblock}
10463+
10464+
\pnum
10465+
The class template \tcode{negation}
10466+
forms the logical negation of its template type argument.
10467+
The type \tcode{negation<B>}
10468+
is a UnaryTypeTrait with a BaseCharacteristic of \tcode{bool_constant<!B::value>}.
10469+
1038310470
\rSec1[ratio]{Compile-time rational arithmetic}
1038410471

1038510472
\rSec2[ratio.general]{In general}

source/xref.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@
912912
memory.syn\quad\ref{memory.syn}\\
913913
meta\quad\ref{meta}\\
914914
meta.help\quad\ref{meta.help}\\
915+
meta.logical\quad\ref{meta.logical}\\
915916
meta.rel\quad\ref{meta.rel}\\
916917
meta.rqmts\quad\ref{meta.rqmts}\\
917918
meta.trans\quad\ref{meta.trans}\\

0 commit comments

Comments
 (0)