aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Smith-Rowland <3dw4rd@verizon.net>2014-10-01 11:59:29 +0000
committerEdward Smith-Rowland <emsr@gcc.gnu.org>2014-10-01 11:59:29 +0000
commit4db7fcb9a806820af731c8f22fafe38701885a19 (patch)
tree7838167ce524eb0879de61855a11c22f0c395952
parenta15f7cb8b8c124bb7c49ab9b8d29dfd62ea58d10 (diff)
downloadgcc-4db7fcb9a806820af731c8f22fafe38701885a19.zip
gcc-4db7fcb9a806820af731c8f22fafe38701885a19.tar.gz
gcc-4db7fcb9a806820af731c8f22fafe38701885a19.tar.bz2
type_traits: Add is_final<> type trait for C++14.
2014-10-01 Edward Smith-Rowland <3dw4rd@verizon.net> * include/std/type_traits: Add is_final<> type trait for C++14. * testsuite/util/testsuite_tr1.h: Add * testsuite/20_util/is_final/requirements/ explicit_instantiation.cc: New. * testsuite/20_util/is_final/requirements/typedefs.cc: New. * testsuite/20_util/is_final/value.cc: New. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust. From-SVN: r215753
-rw-r--r--libstdc++-v3/ChangeLog12
-rw-r--r--libstdc++-v3/include/std/type_traits9
-rw-r--r--libstdc++-v3/testsuite/20_util/is_final/requirements/explicit_instantiation.cc29
-rw-r--r--libstdc++-v3/testsuite/20_util/is_final/requirements/typedefs.cc34
-rw-r--r--libstdc++-v3/testsuite/20_util/is_final/value.cc35
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_tr1.h4
6 files changed, 123 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 78609fa..02ffb3e 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,17 @@
2014-10-01 Edward Smith-Rowland <3dw4rd@verizon.net>
+ * include/std/type_traits: Add is_final<> type trait for C++14.
+ * testsuite/util/testsuite_tr1.h: Add
+ * testsuite/20_util/is_final/requirements/
+ explicit_instantiation.cc: New.
+ * testsuite/20_util/is_final/requirements/typedefs.cc: New.
+ * testsuite/20_util/is_final/value.cc: New.
+ * testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
+ * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust.
+ * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust.
+
+2014-10-01 Edward Smith-Rowland <3dw4rd@verizon.net>
+
Implement SD-6: SG10 Feature Test Recommendations
* include/bits/basic_string.h: Add __cpp_lib feature test macro.
* include/bits/stl_algobase.h: Ditto.
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 86dd6f9..6690044 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -639,6 +639,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: public integral_constant<bool, __is_polymorphic(_Tp)>
{ };
+#if __cplusplus >= 201402L
+#define __cpp_lib_is_final 201402L
+ /// is_final
+ template<typename _Tp>
+ struct is_final
+ : public integral_constant<bool, __is_final(_Tp)>
+ { };
+#endif
+
/// is_abstract
template<typename _Tp>
struct is_abstract
diff --git a/libstdc++-v3/testsuite/20_util/is_final/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_final/requirements/explicit_instantiation.cc
new file mode 100644
index 0000000..c5d44e6
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_final/requirements/explicit_instantiation.cc
@@ -0,0 +1,29 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 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
+{
+ typedef short test_type;
+ template struct is_final<test_type>;
+}
diff --git a/libstdc++-v3/testsuite/20_util/is_final/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_final/requirements/typedefs.cc
new file mode 100644
index 0000000..b07d90b
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_final/requirements/typedefs.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2014 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>
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::is_final<int> 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/is_final/value.cc b/libstdc++-v3/testsuite/20_util/is_final/value.cc
new file mode 100644
index 0000000..281c1ab
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/is_final/value.cc
@@ -0,0 +1,35 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do compile }
+
+// Copyright (C) 2011-2014 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>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ using std::is_final;
+ using namespace __gnu_test;
+
+ // Positive test.
+ static_assert(test_category<is_final, FinalType>(true), "");
+
+ // Negative tests.
+ static_assert(test_category<is_final, ClassType>(false), "");
+ static_assert(test_category<is_final, DerivedType>(false), "");
+}
diff --git a/libstdc++-v3/testsuite/util/testsuite_tr1.h b/libstdc++-v3/testsuite/util/testsuite_tr1.h
index aa80a21..6e96296 100644
--- a/libstdc++-v3/testsuite/util/testsuite_tr1.h
+++ b/libstdc++-v3/testsuite/util/testsuite_tr1.h
@@ -100,6 +100,10 @@ namespace __gnu_test
class DerivedType : public ClassType { };
+#if __cplusplus >= 201103L
+ class FinalType final : public DerivedType { };
+#endif
+
enum EnumType { e0 };
struct ConvType