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  <suwangl...@gmail.com>
+ * 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  <jwak...@redhat.com>

  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<!bool(_Pp::value)>
     { };

+  template<typename ...>
+    struct __xor_;
+
+  template<>
+ struct __xor_<>
+ : public true_type
+ { };
+
+  template<typename _B1>
+    struct __xor_<_B1>
+ : public _B1
+ { };
+
+  template<typename _B1, typename _B2>
+    struct __xor_<_B1, _B2>
+ : public __and_<__or_<_B1, _B2>,__not_<__and_<_B1, _B2>>>
+ { };
+
+  template<typename _B1, typename _B2, typename _B3, typename... _Bn>
+    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<typename... _Bn>
@@ -148,6 +171,10 @@
     inline constexpr bool __or_v = __or_<_Bn...>::value;
   template<typename... _Bn>
     inline constexpr bool __and_v = __and_<_Bn...>::value;
+  template<typename... _Bn>
+    inline constexpr bool __not_v = __not_<_Bn...>::value;
+  template<typename... _Bn>
+    inline constexpr bool __xor_v = __xor_<_Bn...>::value;

 #define __cpp_lib_logical_traits 201510

@@ -165,8 +192,27 @@
     struct negation
     : __not_<_Pp>
     { };
-
   template<typename... _Bn>
+    struct exclusive_or
+ : __xor_<_Bn...>
+ { };
+
+  template<typename... _Bn>
+    struct not_conjunction
+ : __not_<__and_<_Bn...>
+ { };
+
+  template<typename... _Bn>
+    struct not_disjunction
+ : __not_<__or_<_Bn...>>
+ { };
+
+  template<typename... _Bn>
+    struct not_exclusive_or
+ : __not_<__xor_<_Bn...>>
+ { };
+
+  template<typename... _Bn>
     inline constexpr bool conjunction_v = conjunction<_Bn...>::value;

   template<typename... _Bn>
@@ -174,6 +220,18 @@

   template<typename _Pp>
     inline constexpr bool negation_v = negation<_Pp>::value;
+
+  template<typename... _Bn>
+    inline constexpr bool exclusive_or_v = exclusive_or<_Bn...>::value;
+
+  template<typename... _Bn>
+    inline constexpr bool not_conjunction_v =
not_conjunction<_Bn...>::value;
+
+  template<typename... _Bn>
+    inline constexpr bool not_disjunction_v =
not_disjunction<_Bn...>::value;
+
+  template<typename... _Bn>
+    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<true_type, true_type>;
   template struct disjunction<false_type, true_type>;
   template struct negation<false_type>;
+  template struct excluesive_or<true_type, true_type>;
+  template struct not_exclusive_or<true_type, true_type>;
+  template struct not_conjunction<true_type, true_type>;
+  template struct not_disjunction<false_type, true_type>;
 }
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<std::true_type, std::true_type>
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<std::false_type, std::true_type>
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 for required typedefs
+  typedef std::excluesive_or<std::true_type, std::true_type>
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 test07()
+{
+  // Check for required typedefs
+  typedef std::not_exclusive_or<std::true_type, std::true_type>
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;
+}
Index: testsuite/20_util/logical_traits/value.cc
===================================================================
--- testsuite/20_util/logical_traits/value.cc (revision 268714)
+++ testsuite/20_util/logical_traits/value.cc (working copy)
@@ -25,21 +25,57 @@
   static_assert(std::negation<std::false_type>{});
   static_assert(!std::negation<std::true_type>{});
   static_assert(std::conjunction<>{});
+  static_assert(!std::not_conjunction<>{});
   static_assert(!std::disjunction<>{});
+  static_assert(std::not_disjunction<>{});
   static_assert(std::conjunction<std::true_type>{});
+  static_assert(!std::not_conjunction<std::true_type>{});
   static_assert(!std::conjunction<std::false_type>{});
+  static_assert(std::not_conjunction<std::false_type>{});
   static_assert(std::disjunction<std::true_type>{});
+  static_assert(!std::not_disjunction<std::true_type>{});
   static_assert(!std::disjunction<std::false_type>{});
+  static_assert(std::not_disjunction<std::false_type>{});
   static_assert(std::conjunction<std::true_type, std::true_type>{});
+  static_assert(!std::not_conjunction<std::true_type, std::true_type>{});
   static_assert(!std::conjunction<std::true_type, std::false_type>{});
+  static_assert(std::not_conjunction<std::true_type, std::false_type>{});
   static_assert(std::disjunction<std::false_type, std::true_type>{});
+  static_assert(!std::not_disjunction<std::false_type, std::true_type>{});
   static_assert(!std::disjunction<std::false_type, std::false_type>{});
+  static_assert(std::not_disjunction<std::false_type, std::false_type>{});
   static_assert(std::conjunction<std::true_type, std::true_type,
                 std::true_type>{});
+  static_assert(!std::not_conjunction<std::true_type, std::true_type,
+                std::true_type>{});
   static_assert(!std::conjunction<std::true_type, std::true_type,
                 std::false_type>{});
+  static_assert(std::not_conjunction<std::true_type, std::true_type,
+                std::false_type>{});
   static_assert(std::disjunction<std::false_type, std::false_type,
                 std::true_type>{});
+  static_assert(!std::not_disjunction<std::false_type, std::false_type,
+                std::true_type>{});
   static_assert(!std::disjunction<std::false_type, std::false_type,
                 std::false_type>{});
+  static_assert(std::not_disjunction<std::false_type, std::false_type,
+                std::false_type>{});
+  static_assert(std::exclusive_or<>{});
+  static_assert(std::exclusive_or<std::true_type>{});
+  static_assert(!std::exclusive_or<std::false_type>{});
+  static_assert(!std::exclusive_or<std::true_type, std::true_type>{});
+  static_assert(std::exclusive_or<std::false_type, std::true_type>{});
+  static_assert(!std::exclusive_or<std::false_type, std::false_type>{});
+  static_assert(std::exclusive_or<std::true_type, std::false_type>{});
+  static_assert(std::exclusive_or<std::true_type, std::true_type,
std::true_type>{});
+  static_assert(!std::exclusive_or<std::true_type, std::true_type,
std::false_type>{});
+  static_assert(!std::not_exclusive_or<>{});
+  static_assert(!std::not_exclusive_or<std::true_type>{});
+  static_assert(std::not_exclusive_or<std::false_type>{});
+  static_assert(std::not_exclusive_or<std::true_type, std::true_type>{});
+  static_assert(!std::not_exclusive_or<std::false_type, std::true_type>{});
+  static_assert(std::not_exclusive_or<std::false_type, std::false_type>{});
+  static_assert(!std::not_exclusive_or<std::true_type, std::false_type>{});
+  static_assert(!std::not_exclusive_or<std::false_type, std::false_type,
std::true_type>{});
+  static_assert(std::not_exclusive_or<std::false_type, std::false_type,
std::false_type>{});
 }

could you please approval my patch or check ? thank you in advance

Reply via email to