type_traits (is_null_pointer): Add.
2013-05-02 Paolo Carlini <paolo.carlini@oracle.com> * include/std/type_traits (is_null_pointer): Add. (__is_nullptr_t): Implement in terms of the latter. (is_fundamental, is_scalar): Adjust. * testsuite/20_util/is_null_pointer/requirements/ explicit_instantiation.cc: New. * testsuite/20_util/is_null_pointer/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_null_pointer/value.cc: Likewise. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error line number. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. From-SVN: r198516
This commit is contained in:
parent
ff84dbcb4e
commit
aa940ab5d5
|
@ -1,3 +1,20 @@
|
|||
2013-05-02 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/std/type_traits (is_null_pointer): Add.
|
||||
(__is_nullptr_t): Implement in terms of the latter.
|
||||
(is_fundamental, is_scalar): Adjust.
|
||||
* testsuite/20_util/is_null_pointer/requirements/
|
||||
explicit_instantiation.cc: New.
|
||||
* testsuite/20_util/is_null_pointer/requirements/typedefs.cc:
|
||||
Likewise.
|
||||
* testsuite/20_util/is_null_pointer/value.cc: Likewise.
|
||||
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
|
||||
line number.
|
||||
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
|
||||
Likewise.
|
||||
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
|
||||
Likewise.
|
||||
|
||||
2013-05-02 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/c_global/cstdio: Add comment about LWG 2249.
|
||||
|
|
|
@ -402,17 +402,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
: public true_type { };
|
||||
|
||||
template<typename>
|
||||
struct __is_nullptr_t_helper
|
||||
struct __is_null_pointer_helper
|
||||
: public false_type { };
|
||||
|
||||
template<>
|
||||
struct __is_nullptr_t_helper<std::nullptr_t>
|
||||
struct __is_null_pointer_helper<std::nullptr_t>
|
||||
: public true_type { };
|
||||
|
||||
// __is_nullptr_t (extension).
|
||||
/// is_null_pointer (LWG 2247).
|
||||
template<typename _Tp>
|
||||
struct is_null_pointer
|
||||
: public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type
|
||||
{ };
|
||||
|
||||
/// __is_nullptr_t (extension).
|
||||
template<typename _Tp>
|
||||
struct __is_nullptr_t
|
||||
: public __is_nullptr_t_helper<typename remove_cv<_Tp>::type>::type
|
||||
: public is_null_pointer<_Tp>
|
||||
{ };
|
||||
|
||||
// Composite type categories.
|
||||
|
@ -433,7 +439,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
/// is_fundamental
|
||||
template<typename _Tp>
|
||||
struct is_fundamental
|
||||
: public __or_<is_arithmetic<_Tp>, is_void<_Tp>, __is_nullptr_t<_Tp>>::type
|
||||
: public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
|
||||
is_null_pointer<_Tp>>::type
|
||||
{ };
|
||||
|
||||
/// is_object
|
||||
|
@ -450,7 +457,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
template<typename _Tp>
|
||||
struct is_scalar
|
||||
: public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
|
||||
is_member_pointer<_Tp>, __is_nullptr_t<_Tp>>::type
|
||||
is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
|
||||
{ };
|
||||
|
||||
/// is_compound
|
||||
|
|
|
@ -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 *-*-* } 1852 }
|
||||
// { dg-error "static assertion failed" "" { target *-*-* } 1859 }
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// { dg-options "-std=gnu++11" }
|
||||
// { dg-do compile }
|
||||
// 2013-05-02 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
// Copyright (C) 2013 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_null_pointer<test_type>;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// { dg-options "-std=gnu++11" }
|
||||
// 2013-05-02 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
//
|
||||
// Copyright (C) 2013 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::is_null_pointer<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,60 @@
|
|||
// { dg-options "-std=gnu++11" }
|
||||
// 2013-05-02 Paolo Carlini <pcarlini@suse.de>
|
||||
//
|
||||
// Copyright (C) 2013 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_null_pointer;
|
||||
using namespace __gnu_test;
|
||||
|
||||
VERIFY( (test_category<is_null_pointer, std::nullptr_t>(true)) );
|
||||
|
||||
VERIFY( (test_category<is_null_pointer, int>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, float>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, EnumType>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, int*>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, int(*)(int)>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, int (ClassType::*)>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, int (ClassType::*) (int)>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, int[2]>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, float[][3]>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, EnumType[2][3][4]>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, int*[3]>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, int(*[][2])(int)>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, int (ClassType::*[2][3])>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer,
|
||||
int (ClassType::*[][2][3]) (int)>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, ClassType>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, PODType>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, void>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, NType>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, TType>(false)) );
|
||||
VERIFY( (test_category<is_null_pointer, SLType>(false)) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -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 *-*-* } 1594 }
|
||||
// { dg-error "declaration of" "" { target *-*-* } 1558 }
|
||||
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1601 }
|
||||
// { dg-error "declaration of" "" { target *-*-* } 1565 }
|
||||
|
|
|
@ -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 *-*-* } 1512 }
|
||||
// { dg-error "declaration of" "" { target *-*-* } 1476 }
|
||||
// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1519 }
|
||||
// { dg-error "declaration of" "" { target *-*-* } 1483 }
|
||||
|
|
Loading…
Reference in New Issue