===================================================================
@@ -193,7 +193,7 @@
{ };
template<typename _Tp>
- typename add_rvalue_reference<_Tp>::type declval();
+ typename add_rvalue_reference<_Tp>::type declval() noexcept;
template<typename _Tp, typename... _Args>
class __is_constructible_helper
@@ -234,6 +234,28 @@
_Args...>::__value>
{ };
+ template<bool, typename _Tp, typename... _Args>
+ struct __is_nt_constructible_helper
+ { static const bool __value = false; };
+
+ template<typename _Tp, typename... _Args>
+ struct __is_nt_constructible_helper<true, _Tp, _Args...>
+ { static const bool __value = noexcept(_Tp(declval<_Args>()...)); };
+
+ template<typename _Tp, typename _Arg>
+ struct __is_nt_constructible_helper<true, _Tp, _Arg>
+ {
+ static const bool __value = noexcept(static_cast<_Tp>(declval<_Arg>()));
+ };
+
+ /// is_nothrow_constructible
+ template<typename _Tp, typename... _Args>
+ struct is_nothrow_constructible
+ : public integral_constant<bool,
+ __is_nt_constructible_helper<is_constructible<_Tp, _Args...>::value,
+ _Tp, _Args...>::__value>
+ { };
+
/// has_trivial_default_constructor
template<typename _Tp>
struct has_trivial_default_constructor
@@ -649,7 +671,7 @@
template<typename _Tp>
inline typename add_rvalue_reference<_Tp>::type
- declval()
+ declval() noexcept
{
static_assert(__declval_protector<_Tp>::__stop,
"declval() must not be used!");
===================================================================
@@ -1,7 +1,8 @@
// -*- C++ -*-
// Testing utilities for the tr1 testsuite.
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010
+// 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
@@ -127,8 +128,39 @@
{
ExplicitClass(double&);
explicit ExplicitClass(int&);
+ ExplicitClass(double&, int&, double&);
};
+ struct NothrowExplicitClass
+ {
+ NothrowExplicitClass(double&) throw();
+ explicit NothrowExplicitClass(int&) throw();
+ NothrowExplicitClass(double&, int&, double&) throw();
+ };
+
+ struct ThrowExplicitClass
+ {
+ ThrowExplicitClass(double&) throw(int);
+ explicit ThrowExplicitClass(int&) throw(int);
+ ThrowExplicitClass(double&, int&, double&) throw(int);
+ };
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ struct NoexceptExplicitClass
+ {
+ NoexceptExplicitClass(double&) noexcept(true);
+ explicit NoexceptExplicitClass(int&) noexcept(true);
+ NoexceptExplicitClass(double&, int&, double&) noexcept(true);
+ };
+
+ struct ExceptExplicitClass
+ {
+ ExceptExplicitClass(double&) noexcept(false);
+ explicit ExceptExplicitClass(int&) noexcept(false);
+ ExceptExplicitClass(double&, int&, double&) noexcept(false);
+ };
+#endif
+
struct NType // neither trivial nor standard-layout
{
int i;
===================================================================
@@ -0,0 +1,78 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-06-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::is_nothrow_constructible;
+ using namespace __gnu_test;
+
+ // Positive tests.
+ VERIFY( (test_property<is_nothrow_constructible, NoexceptExplicitClass,
+ double&>(true)) );
+ VERIFY( (test_property<is_nothrow_constructible, NoexceptExplicitClass,
+ int&>(true)) );
+ VERIFY( (test_property<is_nothrow_constructible, NoexceptExplicitClass,
+ double&, int&, double&>(true)) );
+ VERIFY( (test_property<is_nothrow_constructible, NothrowExplicitClass,
+ double&>(true)) );
+ VERIFY( (test_property<is_nothrow_constructible, NothrowExplicitClass,
+ int&>(true)) );
+ VERIFY( (test_property<is_nothrow_constructible, NothrowExplicitClass,
+ double&, int&, double&>(true)) );
+
+ // Negative tests.
+ VERIFY( (test_property<is_nothrow_constructible, NoexceptExplicitClass,
+ void*>(false)) );
+ VERIFY( (test_property<is_nothrow_constructible, NoexceptExplicitClass>
+ (false)) );
+ VERIFY( (test_property<is_nothrow_constructible, NoexceptExplicitClass,
+ int, double>(false)) );
+ VERIFY( (test_property<is_nothrow_constructible, NothrowExplicitClass,
+ void*>(false)) );
+ VERIFY( (test_property<is_nothrow_constructible, NothrowExplicitClass>
+ (false)) );
+ VERIFY( (test_property<is_nothrow_constructible, NothrowExplicitClass,
+ int, double>(false)) );
+
+ VERIFY( (test_property<is_nothrow_constructible, ExceptExplicitClass,
+ double&>(false)) );
+ VERIFY( (test_property<is_nothrow_constructible, ExceptExplicitClass,
+ int&>(false)) );
+ VERIFY( (test_property<is_nothrow_constructible, ExceptExplicitClass,
+ double&, int&, double&>(false)) );
+ VERIFY( (test_property<is_nothrow_constructible, ThrowExplicitClass,
+ double&>(false)) );
+ VERIFY( (test_property<is_nothrow_constructible, ThrowExplicitClass,
+ int&>(false)) );
+ VERIFY( (test_property<is_nothrow_constructible, ThrowExplicitClass,
+ double&, int&, double&>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
===================================================================
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-06-09 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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_nothrow_constructible<int, 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;
+}
===================================================================
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// 2010-06-09 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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_nothrow_constructible<test_type, test_type>;
+}
===================================================================
@@ -48,8 +48,8 @@
// { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 617 }
-// { dg-error "declaration of" "" { target *-*-* } 581 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 639 }
+// { dg-error "declaration of" "" { target *-*-* } 603 }
// { dg-excess-errors "At global scope" }
// { dg-excess-errors "In instantiation of" }
===================================================================
@@ -48,8 +48,8 @@
// { dg-error "instantiated from here" "" { target *-*-* } 40 }
// { dg-error "instantiated from here" "" { target *-*-* } 42 }
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 540 }
-// { dg-error "declaration of" "" { target *-*-* } 504 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 562 }
+// { dg-error "declaration of" "" { target *-*-* } 526 }
// { dg-excess-errors "At global scope" }
// { dg-excess-errors "In instantiation of" }
===================================================================
@@ -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 *-*-* } 654 }
+// { dg-error "static assertion failed" "" { target *-*-* } 676 }
// { dg-error "instantiated from here" "" { target *-*-* } 30 }
// { dg-excess-errors "In function" }