hi all,
I have a patch about libstdc++
include/std/type_traits ,
testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc
testsuite/20_util/logical_traits/requirements/typedefs.cc
testsuite/20_util/logical_traits/value.cc,
the patch want to add new logical traits , such as exclusive_or ,
not_exclusive_or, not_conjunction and not_disjunction for logical
completeness , the detail patch as below:
Index: ChangeLog
===
--- ChangeLog (revision 268714)
+++ ChangeLog (working copy)
@@ -1,3 +1,12 @@
+2019-02-09 lisuwang
+ * include/std/type_traits(__xor_<..>, excluesive_or<...>,
not_exclusive_or<...>, not_conjunction<...>, not_disjunction<...>): Define.
+ * testsuite/20_util/logical_traits/value.cc: Add
+ additional cases for std::not_conjunction, std::not_disjunction,
std::excluesive_or and std::not_exclusive_or.
+ *
testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc: Add
+ explicit_instantiation of std::not_conjunction, std::not_disjunction,
std::excluesive_or and std::not_exclusive_or.
+ * testsuite/20_util/logical_traits/requirements/typedefs.cc: Add
+ the additional test cases to verify the typedefs.
+
2019-02-09 Jonathan Wakely
PR libstdc++/71044
Index: include/std/type_traits
===
--- include/std/type_traits (revision 268714)
+++ include/std/type_traits (working copy)
@@ -142,6 +142,29 @@
: public __bool_constant
{ };
+ template
+struct __xor_;
+
+ template<>
+ struct __xor_<>
+ : public true_type
+ { };
+
+ template
+struct __xor_<_B1>
+ : public _B1
+ { };
+
+ template
+struct __xor_<_B1, _B2>
+ : public __and_<__or_<_B1, _B2>,__not_<__and_<_B1, _B2>>>
+ { };
+
+ template
+struct __xor_<_B1, _B2,_B3,_Bn...>
+ : public __and_<__or_<_B1,__xor_<_B2,_B3,_Bn...>>,
__not_<__and_<_B1,__xor_<_B2,_B3,_Bn...
+ { };
+
#if __cplusplus >= 201703L
template
@@ -148,6 +171,10 @@
inline constexpr bool __or_v = __or_<_Bn...>::value;
template
inline constexpr bool __and_v = __and_<_Bn...>::value;
+ template
+inline constexpr bool __not_v = __not_<_Bn...>::value;
+ template
+inline constexpr bool __xor_v = __xor_<_Bn...>::value;
#define __cpp_lib_logical_traits 201510
@@ -165,8 +192,27 @@
struct negation
: __not_<_Pp>
{ };
-
template
+struct exclusive_or
+ : __xor_<_Bn...>
+ { };
+
+ template
+struct not_conjunction
+ : __not_<__and_<_Bn...>
+ { };
+
+ template
+struct not_disjunction
+ : __not_<__or_<_Bn...>>
+ { };
+
+ template
+struct not_exclusive_or
+ : __not_<__xor_<_Bn...>>
+ { };
+
+ template
inline constexpr bool conjunction_v = conjunction<_Bn...>::value;
template
@@ -174,6 +220,18 @@
template
inline constexpr bool negation_v = negation<_Pp>::value;
+
+ template
+inline constexpr bool exclusive_or_v = exclusive_or<_Bn...>::value;
+
+ template
+inline constexpr bool not_conjunction_v =
not_conjunction<_Bn...>::value;
+
+ template
+inline constexpr bool not_disjunction_v =
not_disjunction<_Bn...>::value;
+
+ template
+inline constexpr bool not_exclusive_or_v =
not_exclusive_or<_Bn...>::value;
#endif // C++17
Index:
testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc
===
--- testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc
(revision
268714)
+++ testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc
(working
copy)
@@ -27,4 +27,8 @@
template struct conjunction;
template struct disjunction;
template struct negation;
+ template struct excluesive_or;
+ template struct not_exclusive_or;
+ template struct not_conjunction;
+ template struct not_disjunction;
}
Index: testsuite/20_util/logical_traits/requirements/typedefs.cc
===
--- testsuite/20_util/logical_traits/requirements/typedefs.cc (revision
268714)
+++ testsuite/20_util/logical_traits/requirements/typedefs.cc (working copy)
@@ -53,3 +53,43 @@
typedef test_type::type::value_type type_value_type;
typedef test_type::type::type type_type;
}
+
+void test04()
+{
+ // Check for required typedefs
+ typedef std::not_conjunction
test_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::type type;
+ typedef test_type::type::value_type type_value_type;
+ typedef test_type::type::type type_type;
+}
+
+void test05()
+{
+ // Check for required typedefs
+ typedef std::not_disjunction
test_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::type type;
+ typedef test_type::type::value_type type_value_type;
+ typedef test_type::type::type type_type;
+}
+
+void test06()
+{
+ // Check