forked from boostorg/type_traits
Implement conjunction, disjunction, negation
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
[/
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License,
|
||||
Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
[section:conjunction conjunction]
|
||||
|
||||
template<class... T>
|
||||
struct conjunction;
|
||||
|
||||
__inherit Inherits from the first type `U` in the list for which
|
||||
`bool(U::value)` is `false`, or the last type in the list if there is no such
|
||||
type. If `sizeof...(T)` is `0` then inherits from `__true_type`.
|
||||
|
||||
__header `#include <boost/type_traits/conjunction.hpp>`
|
||||
|
||||
[all_compilers] In the absence of variadic-template support, `conjunction` has
|
||||
only 2 parameters.
|
||||
|
||||
__examples
|
||||
|
||||
[:Given: `template<int N> struct Int { static const int value = N };` ]
|
||||
|
||||
[:`conjunction<>` inherits from `__true_type`.]
|
||||
|
||||
[:`conjunction<Int<1> >` inherits from `Int<1>`.]
|
||||
|
||||
[:`conjunction<Int<1>, Int<2>, Int<3> >` inherits from `Int<3>`.]
|
||||
|
||||
[:`conjunction<Int<1>, Int<0>, Int<3> >` inherits from `Int<0>`.]
|
||||
|
||||
[endsect]
|
||||
@@ -0,0 +1,36 @@
|
||||
[/
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License,
|
||||
Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
[section:disjunction disjunction]
|
||||
|
||||
template<class... T>
|
||||
struct disjunction;
|
||||
|
||||
__inherit Inherits from the first type `U` in the list for which
|
||||
`bool(U::value)` is `true`, or the last type in the list if there is no such
|
||||
type. If `sizeof...(T)` is `0` then inherits from `__false_type`.
|
||||
|
||||
__header `#include <boost/type_traits/disjunction.hpp>`
|
||||
|
||||
[all_compilers] In the absence of variadic-template support, `disjunction` has
|
||||
only 2 parameters.
|
||||
|
||||
__examples
|
||||
|
||||
[:Given: `template<int N> struct Int { static const int value = N };` ]
|
||||
|
||||
[:`disjunction<>` inherits from `__false_type`.]
|
||||
|
||||
[:`disjunction<Int<1> >` inherits from `Int<1>`.]
|
||||
|
||||
[:`disjunction<Int<1>, Int<2>, Int<3> >` inherits from `Int<1>`.]
|
||||
|
||||
[:`disjunction<Int<0>, Int<2>, Int<3> >` inherits from `Int<2>`.]
|
||||
|
||||
[endsect]
|
||||
@@ -0,0 +1,35 @@
|
||||
[/
|
||||
Copyright 2020 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License,
|
||||
Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
or copy at http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
[section:negation negation]
|
||||
|
||||
template<class T>
|
||||
struct negation
|
||||
: public __integral_constant<bool, !bool(T::value)> { };
|
||||
|
||||
__inherit Inherits from `__integral_constant<bool, !bool(T::value)>`.
|
||||
|
||||
__header `#include <boost/type_traits/negation.hpp>`
|
||||
|
||||
[all_compilers]
|
||||
|
||||
__examples
|
||||
|
||||
[:`negation<__true_type>` inherits from `__false_type`.]
|
||||
|
||||
[:`negation<__false_type>` inherits from `__true_type`.]
|
||||
|
||||
[:`negation<__integral_constant<int, 4> >::type` is the type `__false_type`.]
|
||||
|
||||
[:`negation<__integral_constant<int, 0> >::value` is an integral constant
|
||||
expression that evaluates to /true/.]
|
||||
|
||||
[:`negation<T>::value_type` is the type `bool`.]
|
||||
|
||||
[endsect]
|
||||
@@ -129,6 +129,9 @@
|
||||
[def __add_cv [link boost_typetraits.reference.add_cv add_cv]]
|
||||
[def __common_type [link boost_typetraits.reference.common_type common_type]]
|
||||
[def __conditional [link boost_typetraits.reference.conditional conditional]]
|
||||
[def __conjunction [link boost_typetraits.reference.conjunction conjunction]]
|
||||
[def __disjunction [link boost_typetraits.reference.disjunction disjunction]]
|
||||
[def __negation [link boost_typetraits.reference.negation negation]]
|
||||
|
||||
[def __type_with_alignment [link boost_typetraits.reference.type_with_alignment type_with_alignment]]
|
||||
[def __aligned_storage [link boost_typetraits.reference.aligned_storage aligned_storage]]
|
||||
@@ -307,6 +310,7 @@ that is the result of the transformation.
|
||||
[include aligned_storage.qbk]
|
||||
[include alignment_of.qbk]
|
||||
[include conditional.qbk]
|
||||
[include conjunction.qbk]
|
||||
[include common_type.qbk]
|
||||
[include copy_cv.qbk]
|
||||
[include copy_cv_ref.qbk]
|
||||
@@ -315,6 +319,7 @@ that is the result of the transformation.
|
||||
[include declval.qbk]
|
||||
[include detected.qbk]
|
||||
[include detected_or.qbk]
|
||||
[include disjunction.qbk]
|
||||
[include enable_if.qbk]
|
||||
[include extent.qbk]
|
||||
[include floating_point_promotion.qbk]
|
||||
@@ -441,6 +446,7 @@ See __has_trivial_constructor.
|
||||
[include make_signed.qbk]
|
||||
[include make_unsigned.qbk]
|
||||
[include make_void.qbk]
|
||||
[include negation.qbk]
|
||||
[include nonesuch.qbk]
|
||||
|
||||
[include promote.qbk]
|
||||
|
||||
Reference in New Issue
Block a user