|
9313 | 9313 | using result_of_t = typename result_of<T>::type;
|
9314 | 9314 | template <class...>
|
9315 | 9315 | 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; |
9316 | 9321 | } // namespace std
|
9317 | 9322 | \end{codeblock}
|
9318 | 9323 |
|
|
10380 | 10385 | \end{codeblock}
|
10381 | 10386 | \exitexample
|
10382 | 10387 |
|
| 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 | + |
10383 | 10470 | \rSec1[ratio]{Compile-time rational arithmetic}
|
10384 | 10471 |
|
10385 | 10472 | \rSec2[ratio.general]{In general}
|
|
0 commit comments