* [v3 PATCH] Implement D0013R2, logical type traits.
@ 2015-11-11 22:06 Ville Voutilainen
2015-11-11 22:18 ` Jonathan Wakely
0 siblings, 1 reply; 4+ messages in thread
From: Ville Voutilainen @ 2015-11-11 22:06 UTC (permalink / raw)
To: gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 882 bytes --]
Tested on Linux-PPC64.
2015-11-11 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement D0013R2, logical type traits.
/libstdc++-v3
* include/experimental/type_traits (conjunction_v, disjunction_v,
negation_v): New.
* include/std/type_traits (conjunction, disjunction, negation):
Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
* testsuite/experimental/type_traits/value.cc: Likewise.
* testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/logical_traits/requirements/typedefs.cc: Likewise.
* testsuite/20_util/logical_traits/value.cc: Likewise.
/testsuite
* g++.dg/cpp0x/Wattributes1.C: Adjust.
[-- Attachment #2: logical_traits.diff --]
[-- Type: text/plain, Size: 12259 bytes --]
diff --git a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C
index d818851..dd9011b 100644
--- a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C
+++ b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C
@@ -5,4 +5,4 @@
#include <new>
__attribute__((visibility("hidden")))void*operator new(std::size_t); // { dg-warning "visibility attribute ignored" }
-// { dg-message "previous declaration" "" { target *-*-* } 111 }
+// { dg-message "previous declaration" "" { target *-*-* } 116 }
diff --git a/libstdc++-v3/include/experimental/type_traits b/libstdc++-v3/include/experimental/type_traits
index b0ed3b0..b7f3bda 100644
--- a/libstdc++-v3/include/experimental/type_traits
+++ b/libstdc++-v3/include/experimental/type_traits
@@ -271,6 +271,28 @@ template<typename _To, template<typename...> class _Op, typename... _Args>
constexpr bool is_detected_convertible_v
= is_detected_convertible<_To, _Op, _Args...>::value;
+#if __cplusplus > 201402L
+
+#define __cpp_lib_experimental_logical_traits 201511
+
+using std::conjunction;
+using std::disjunction;
+using std::negation;
+
+template<typename... _Bn>
+ constexpr bool conjunction_v
+ = conjunction<_Bn...>::value;
+
+template<typename... _Bn>
+ constexpr bool disjunction_v
+ = disjunction<_Bn...>::value;
+
+template<typename _Pp>
+ constexpr bool negation_v
+ = negation<_Pp>::value;
+
+#endif
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace fundamentals_v2
} // namespace experimental
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 7448d5b..e5102de 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -154,6 +154,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public integral_constant<bool, !_Pp::value>
{ };
+#if __cplusplus > 201402L
+
+#define __cpp_lib_logical_traits 201511
+
+ template<typename... _Bn>
+ struct conjunction
+ : __and_<_Bn...>
+ { };
+
+ template<typename... _Bn>
+ struct disjunction
+ : __or_<_Bn...>
+ { };
+
+ template<typename _Pp>
+ struct negation
+ : __not_<_Pp>
+ { };
+#endif
+
// For several sfinae-friendly trait implementations we transport both the
// result information (as the member type) and the failure information (no
// member type). This is very similar to std::enable_if, but we cannot use
diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
index 4e7deda..37bc6b1 100644
--- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
@@ -19,7 +19,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-error "static assertion failed" "" { target *-*-* } 2239 }
+// { dg-error "static assertion failed" "" { target *-*-* } 2259 }
#include <utility>
diff --git a/libstdc++-v3/testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc
new file mode 100644
index 0000000..b2b6c71
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+namespace std
+{
+ template struct conjunction<true_type, true_type>;
+ template struct disjunction<false_type, true_type>;
+ template struct negation<false_type>;
+}
diff --git a/libstdc++-v3/testsuite/20_util/logical_traits/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/typedefs.cc
new file mode 100644
index 0000000..ea102f8
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/typedefs.cc
@@ -0,0 +1,55 @@
+// { dg-options "-std=gnu++17" }
+//
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+//
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::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 test02()
+{
+ // Check for required typedefs
+ typedef std::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 test03()
+{
+ // Check for required typedefs
+ typedef std::negation<std::false_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;
+}
diff --git a/libstdc++-v3/testsuite/20_util/logical_traits/value.cc b/libstdc++-v3/testsuite/20_util/logical_traits/value.cc
new file mode 100644
index 0000000..1da95a3
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/logical_traits/value.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+//
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <type_traits>
+
+void test01()
+{
+ static_assert(std::negation<std::false_type>{});
+ static_assert(!std::negation<std::true_type>{});
+ static_assert(std::conjunction<>{});
+ static_assert(!std::disjunction<>{});
+ static_assert(std::conjunction<std::true_type>{});
+ static_assert(!std::conjunction<std::false_type>{});
+ static_assert(std::disjunction<std::true_type>{});
+ static_assert(!std::disjunction<std::false_type>{});
+ static_assert(std::conjunction<std::true_type, std::true_type>{});
+ static_assert(!std::conjunction<std::true_type, std::false_type>{});
+ static_assert(std::disjunction<std::false_type, std::true_type>{});
+ static_assert(!std::disjunction<std::false_type, std::false_type>{});
+ static_assert(std::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::disjunction<std::false_type, std::false_type,
+ std::true_type>{});
+ static_assert(!std::disjunction<std::false_type, std::false_type,
+ std::false_type>{});
+}
diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
index 8e5fe53..9fbd95b 100644
--- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
@@ -48,4 +48,4 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 40 }
// { dg-error "required from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1904 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1924 }
diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
index 4cd0311..8060aee 100644
--- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
@@ -48,5 +48,5 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 40 }
// { dg-error "required from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1800 }
-// { dg-error "declaration of" "" { target *-*-* } 1757 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1820 }
+// { dg-error "declaration of" "" { target *-*-* } 1777 }
diff --git a/libstdc++-v3/testsuite/experimental/type_traits/value.cc b/libstdc++-v3/testsuite/experimental/type_traits/value.cc
index fefe523..46ee2e4 100644
--- a/libstdc++-v3/testsuite/experimental/type_traits/value.cc
+++ b/libstdc++-v3/testsuite/experimental/type_traits/value.cc
@@ -1,4 +1,4 @@
-// { dg-options "-std=gnu++14" }
+// { dg-options "-std=gnu++17" }
// { dg-do compile }
// Copyright (C) 2014-2015 Free Software Foundation, Inc.
@@ -21,7 +21,7 @@
#include <experimental/type_traits>
using namespace std;
-using namespace std::experimental;
+using namespace experimental;
// These tests are rather simple, the front-end tests already test
// variable templates, and the library tests for the underlying
@@ -322,3 +322,24 @@ static_assert(is_convertible_v<int&, const int&>
&& is_convertible<int&, const int&>::value, "");
static_assert(!is_convertible_v<const int&, int&>
&& !is_convertible<const int&, int&>::value, "");
+
+static_assert(negation_v<false_type>);
+static_assert(!negation_v<true_type>);
+static_assert(conjunction_v<>);
+static_assert(!disjunction_v<>);
+static_assert(conjunction_v<true_type>);
+static_assert(!conjunction_v<false_type>);
+static_assert(disjunction_v<true_type>);
+static_assert(!disjunction_v<false_type>);
+static_assert(conjunction_v<true_type, true_type>);
+static_assert(!conjunction_v<true_type, false_type>);
+static_assert(disjunction_v<false_type, true_type>);
+static_assert(!disjunction_v<false_type, false_type>);
+static_assert(conjunction_v<true_type, true_type,
+ true_type>);
+static_assert(!conjunction_v<true_type, true_type,
+ false_type>);
+static_assert(disjunction_v<false_type, false_type,
+ true_type>);
+static_assert(!disjunction_v<false_type, false_type,
+ false_type>);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [v3 PATCH] Implement D0013R2, logical type traits.
2015-11-11 22:06 [v3 PATCH] Implement D0013R2, logical type traits Ville Voutilainen
@ 2015-11-11 22:18 ` Jonathan Wakely
2015-11-11 22:46 ` Ville Voutilainen
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2015-11-11 22:18 UTC (permalink / raw)
To: Ville Voutilainen; +Cc: gcc-patches, libstdc++
On 12/11/15 00:06 +0200, Ville Voutilainen wrote:
>--- a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C
>+++ b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C
>@@ -5,4 +5,4 @@
> #include <new>
> __attribute__((visibility("hidden")))void*operator new(std::size_t); // { dg-warning "visibility attribute ignored" }
>
>-// { dg-message "previous declaration" "" { target *-*-* } 111 }
>+// { dg-message "previous declaration" "" { target *-*-* } 116 }
>diff --git a/libstdc++-v3/include/experimental/type_traits b/libstdc++-v3/include/experimental/type_traits
>index b0ed3b0..b7f3bda 100644
>--- a/libstdc++-v3/include/experimental/type_traits
>+++ b/libstdc++-v3/include/experimental/type_traits
>@@ -271,6 +271,28 @@ template<typename _To, template<typename...> class _Op, typename... _Args>
> constexpr bool is_detected_convertible_v
> = is_detected_convertible<_To, _Op, _Args...>::value;
>
>+#if __cplusplus > 201402L
>+
>+#define __cpp_lib_experimental_logical_traits 201511
>+
>+using std::conjunction;
>+using std::disjunction;
>+using std::negation;
It's unfortunate if the std::experimental versions are only available
for C++17 mode, because the whole point of putting it into both C++17
and the TS was that users can make us of the std::experimental
versions sooner than they can make use of C++17 version. If both
versions depend on using -std=c++17 then the TS versions are entirely
redundant.
So I think we want to define them again, independently, in
<experimental/type_traits>, even though it might lead to ambiguities
for code that does:
using namespace std;
using namespace std::experimental;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [v3 PATCH] Implement D0013R2, logical type traits.
2015-11-11 22:18 ` Jonathan Wakely
@ 2015-11-11 22:46 ` Ville Voutilainen
2015-11-12 13:41 ` Jonathan Wakely
0 siblings, 1 reply; 4+ messages in thread
From: Ville Voutilainen @ 2015-11-11 22:46 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc-patches, libstdc++
[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]
On 12 November 2015 at 00:18, Jonathan Wakely <jwakely@redhat.com> wrote:
> So I think we want to define them again, independently, in
> <experimental/type_traits>, even though it might lead to ambiguities
Here. Tested again on Linux-PPC64.
2015-11-11 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement D0013R2, logical type traits.
/libstdc++-v3
* include/experimental/type_traits (conjunction, disjunction,
negation, conjunction_v, disjunction_v, negation_v): New.
* include/std/type_traits (conjunction, disjunction, negation):
Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
* testsuite/experimental/type_traits/value.cc: Likewise.
* testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/logical_traits/requirements/typedefs.cc: Likewise.
* testsuite/20_util/logical_traits/value.cc: Likewise.
/testsuite
* g++.dg/cpp0x/Wattributes1.C: Adjust.
[-- Attachment #2: logical_traits3.diff --]
[-- Type: text/plain, Size: 12206 bytes --]
diff --git a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C
index d818851..dd9011b 100644
--- a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C
+++ b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C
@@ -5,4 +5,4 @@
#include <new>
__attribute__((visibility("hidden")))void*operator new(std::size_t); // { dg-warning "visibility attribute ignored" }
-// { dg-message "previous declaration" "" { target *-*-* } 111 }
+// { dg-message "previous declaration" "" { target *-*-* } 116 }
diff --git a/libstdc++-v3/include/experimental/type_traits b/libstdc++-v3/include/experimental/type_traits
index b0ed3b0..e4f3ffe 100644
--- a/libstdc++-v3/include/experimental/type_traits
+++ b/libstdc++-v3/include/experimental/type_traits
@@ -271,6 +271,35 @@ template<typename _To, template<typename...> class _Op, typename... _Args>
constexpr bool is_detected_convertible_v
= is_detected_convertible<_To, _Op, _Args...>::value;
+#define __cpp_lib_experimental_logical_traits 201511
+
+template<typename... _Bn>
+ struct conjunction
+ : __and_<_Bn...>
+ { };
+
+template<typename... _Bn>
+ struct disjunction
+ : __or_<_Bn...>
+ { };
+
+template<typename _Pp>
+ struct negation
+ : __not_<_Pp>
+ { };
+
+template<typename... _Bn>
+ constexpr bool conjunction_v
+ = conjunction<_Bn...>::value;
+
+template<typename... _Bn>
+ constexpr bool disjunction_v
+ = disjunction<_Bn...>::value;
+
+template<typename _Pp>
+ constexpr bool negation_v
+ = negation<_Pp>::value;
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace fundamentals_v2
} // namespace experimental
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 7448d5b..e5102de 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -154,6 +154,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public integral_constant<bool, !_Pp::value>
{ };
+#if __cplusplus > 201402L
+
+#define __cpp_lib_logical_traits 201511
+
+ template<typename... _Bn>
+ struct conjunction
+ : __and_<_Bn...>
+ { };
+
+ template<typename... _Bn>
+ struct disjunction
+ : __or_<_Bn...>
+ { };
+
+ template<typename _Pp>
+ struct negation
+ : __not_<_Pp>
+ { };
+#endif
+
// For several sfinae-friendly trait implementations we transport both the
// result information (as the member type) and the failure information (no
// member type). This is very similar to std::enable_if, but we cannot use
diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
index 4e7deda..37bc6b1 100644
--- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
@@ -19,7 +19,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-error "static assertion failed" "" { target *-*-* } 2239 }
+// { dg-error "static assertion failed" "" { target *-*-* } 2259 }
#include <utility>
diff --git a/libstdc++-v3/testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc
new file mode 100644
index 0000000..b2b6c71
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+namespace std
+{
+ template struct conjunction<true_type, true_type>;
+ template struct disjunction<false_type, true_type>;
+ template struct negation<false_type>;
+}
diff --git a/libstdc++-v3/testsuite/20_util/logical_traits/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/typedefs.cc
new file mode 100644
index 0000000..ea102f8
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/typedefs.cc
@@ -0,0 +1,55 @@
+// { dg-options "-std=gnu++17" }
+//
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+//
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::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 test02()
+{
+ // Check for required typedefs
+ typedef std::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 test03()
+{
+ // Check for required typedefs
+ typedef std::negation<std::false_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;
+}
diff --git a/libstdc++-v3/testsuite/20_util/logical_traits/value.cc b/libstdc++-v3/testsuite/20_util/logical_traits/value.cc
new file mode 100644
index 0000000..1da95a3
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/logical_traits/value.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+//
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <type_traits>
+
+void test01()
+{
+ static_assert(std::negation<std::false_type>{});
+ static_assert(!std::negation<std::true_type>{});
+ static_assert(std::conjunction<>{});
+ static_assert(!std::disjunction<>{});
+ static_assert(std::conjunction<std::true_type>{});
+ static_assert(!std::conjunction<std::false_type>{});
+ static_assert(std::disjunction<std::true_type>{});
+ static_assert(!std::disjunction<std::false_type>{});
+ static_assert(std::conjunction<std::true_type, std::true_type>{});
+ static_assert(!std::conjunction<std::true_type, std::false_type>{});
+ static_assert(std::disjunction<std::false_type, std::true_type>{});
+ static_assert(!std::disjunction<std::false_type, std::false_type>{});
+ static_assert(std::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::disjunction<std::false_type, std::false_type,
+ std::true_type>{});
+ static_assert(!std::disjunction<std::false_type, std::false_type,
+ std::false_type>{});
+}
diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
index 8e5fe53..9fbd95b 100644
--- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
@@ -48,4 +48,4 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 40 }
// { dg-error "required from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1904 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1924 }
diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
index 4cd0311..8060aee 100644
--- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
@@ -48,5 +48,5 @@ void test01()
// { dg-error "required from here" "" { target *-*-* } 40 }
// { dg-error "required from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1800 }
-// { dg-error "declaration of" "" { target *-*-* } 1757 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1820 }
+// { dg-error "declaration of" "" { target *-*-* } 1777 }
diff --git a/libstdc++-v3/testsuite/experimental/type_traits/value.cc b/libstdc++-v3/testsuite/experimental/type_traits/value.cc
index fefe523..d52b454 100644
--- a/libstdc++-v3/testsuite/experimental/type_traits/value.cc
+++ b/libstdc++-v3/testsuite/experimental/type_traits/value.cc
@@ -21,7 +21,7 @@
#include <experimental/type_traits>
using namespace std;
-using namespace std::experimental;
+using namespace experimental;
// These tests are rather simple, the front-end tests already test
// variable templates, and the library tests for the underlying
@@ -322,3 +322,24 @@ static_assert(is_convertible_v<int&, const int&>
&& is_convertible<int&, const int&>::value, "");
static_assert(!is_convertible_v<const int&, int&>
&& !is_convertible<const int&, int&>::value, "");
+
+static_assert(negation_v<false_type>);
+static_assert(!negation_v<true_type>);
+static_assert(conjunction_v<>);
+static_assert(!disjunction_v<>);
+static_assert(conjunction_v<true_type>);
+static_assert(!conjunction_v<false_type>);
+static_assert(disjunction_v<true_type>);
+static_assert(!disjunction_v<false_type>);
+static_assert(conjunction_v<true_type, true_type>);
+static_assert(!conjunction_v<true_type, false_type>);
+static_assert(disjunction_v<false_type, true_type>);
+static_assert(!disjunction_v<false_type, false_type>);
+static_assert(conjunction_v<true_type, true_type,
+ true_type>);
+static_assert(!conjunction_v<true_type, true_type,
+ false_type>);
+static_assert(disjunction_v<false_type, false_type,
+ true_type>);
+static_assert(!disjunction_v<false_type, false_type,
+ false_type>);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [v3 PATCH] Implement D0013R2, logical type traits.
2015-11-11 22:46 ` Ville Voutilainen
@ 2015-11-12 13:41 ` Jonathan Wakely
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2015-11-12 13:41 UTC (permalink / raw)
To: Ville Voutilainen; +Cc: gcc-patches, libstdc++
On 12/11/15 00:46 +0200, Ville Voutilainen wrote:
>On 12 November 2015 at 00:18, Jonathan Wakely <jwakely@redhat.com> wrote:
>> So I think we want to define them again, independently, in
>> <experimental/type_traits>, even though it might lead to ambiguities
>
>Here. Tested again on Linux-PPC64.
>
>2015-11-11 Ville Voutilainen <ville.voutilainen@gmail.com>
>
> Implement D0013R2, logical type traits.
>
> /libstdc++-v3
> * include/experimental/type_traits (conjunction, disjunction,
> negation, conjunction_v, disjunction_v, negation_v): New.
> * include/std/type_traits (conjunction, disjunction, negation):
> Likewise.
> * testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
> * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise.
> * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
> Likewise.
> * testsuite/experimental/type_traits/value.cc: Likewise.
> * testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc:
>New.
> * testsuite/20_util/logical_traits/requirements/typedefs.cc: Likewise.
> * testsuite/20_util/logical_traits/value.cc: Likewise.
>
> /testsuite
> * g++.dg/cpp0x/Wattributes1.C: Adjust.
OK for trunk, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-12 13:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-11 22:06 [v3 PATCH] Implement D0013R2, logical type traits Ville Voutilainen
2015-11-11 22:18 ` Jonathan Wakely
2015-11-11 22:46 ` Ville Voutilainen
2015-11-12 13:41 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).