mirror of git://gcc.gnu.org/git/gcc.git
type_traits (struct underlying_type): Add.
2011-04-25 Paolo Carlini <paolo.carlini@oracle.com> * include/std/type_traits (struct underlying_type): Add. * testsuite/20_util/underlying_type/requirements/typedefs-1.cc: New. * testsuite/20_util/underlying_type/requirements/typedefs-2.cc: Likewise. * testsuite/20_util/underlying_type/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error line number. From-SVN: r172944
This commit is contained in:
parent
a0d260fcc5
commit
a47407f631
|
@ -1,3 +1,14 @@
|
||||||
|
2011-04-25 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
* include/std/type_traits (struct underlying_type): Add.
|
||||||
|
* testsuite/20_util/underlying_type/requirements/typedefs-1.cc: New.
|
||||||
|
* testsuite/20_util/underlying_type/requirements/typedefs-2.cc:
|
||||||
|
Likewise.
|
||||||
|
* testsuite/20_util/underlying_type/requirements/
|
||||||
|
explicit_instantiation.cc: Likewise.
|
||||||
|
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
|
||||||
|
line number.
|
||||||
|
|
||||||
2011-04-24 Paolo Carlini <paolo.carlini@oracle.com>
|
2011-04-24 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
* include/parallel/multiway_merge.h: Uglify equally_split
|
* include/parallel/multiway_merge.h: Uglify equally_split
|
||||||
|
|
|
@ -1581,7 +1581,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
|
common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// underlying_type (still unimplemented)
|
/// underlying_type
|
||||||
|
template<typename _Tp>
|
||||||
|
struct underlying_type
|
||||||
|
{
|
||||||
|
typedef __underlying_type(_Tp) type;
|
||||||
|
};
|
||||||
|
|
||||||
/// declval
|
/// declval
|
||||||
template<typename _Tp>
|
template<typename _Tp>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// with this library; see the file COPYING3. If not see
|
// with this library; see the file COPYING3. If not see
|
||||||
// <http://www.gnu.org/licenses/>.
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// { dg-error "static assertion failed" "" { target *-*-* } 1598 }
|
// { dg-error "static assertion failed" "" { target *-*-* } 1603 }
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
// { dg-do compile }
|
||||||
|
|
||||||
|
// Copyright (C) 2011 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 enum E1 : unsigned { } test_type1;
|
||||||
|
typedef enum E2 : char { } test_type2;
|
||||||
|
typedef enum class E3 { } test_type3;
|
||||||
|
typedef enum class E4 : unsigned char { c = 1 } test_type4;
|
||||||
|
typedef enum class E5 : int { a = -1, b = 1 } test_type5;
|
||||||
|
typedef enum class E6 : long { c = __LONG_MAX__ } test_type6;
|
||||||
|
|
||||||
|
template struct underlying_type<test_type1>;
|
||||||
|
template struct underlying_type<test_type2>;
|
||||||
|
template struct underlying_type<test_type3>;
|
||||||
|
template struct underlying_type<test_type4>;
|
||||||
|
template struct underlying_type<test_type5>;
|
||||||
|
template struct underlying_type<test_type6>;
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
// { dg-do compile }
|
||||||
|
//
|
||||||
|
// Copyright (C) 2011 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()
|
||||||
|
{
|
||||||
|
typedef enum E1 : unsigned { } test_type1;
|
||||||
|
typedef enum E2 : char { } test_type2;
|
||||||
|
typedef enum class E3 { } test_type3;
|
||||||
|
typedef enum class E4 : unsigned char { c = 1 } test_type4;
|
||||||
|
typedef enum class E5 : int { a = -1, b = 1 } test_type5;
|
||||||
|
typedef enum class E6 : long { c = __LONG_MAX__ } test_type6;
|
||||||
|
|
||||||
|
// Check for required typedef
|
||||||
|
typedef std::underlying_type<test_type1>::type type1;
|
||||||
|
typedef std::underlying_type<test_type2>::type type2;
|
||||||
|
typedef std::underlying_type<test_type3>::type type3;
|
||||||
|
typedef std::underlying_type<test_type4>::type type4;
|
||||||
|
typedef std::underlying_type<test_type5>::type type5;
|
||||||
|
typedef std::underlying_type<test_type6>::type type6;
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
// { dg-do compile }
|
||||||
|
//
|
||||||
|
// Copyright (C) 2011 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()
|
||||||
|
{
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
enum E1 : unsigned { };
|
||||||
|
enum E2 : char { };
|
||||||
|
enum class E3 { };
|
||||||
|
enum class E4 : unsigned char { c = 1 };
|
||||||
|
enum class E5 : int { a = -1, b = 1 };
|
||||||
|
enum class E6 : long { c = __LONG_MAX__ };
|
||||||
|
|
||||||
|
static_assert(is_same<underlying_type<E1>::type, unsigned>::value, "Error");
|
||||||
|
static_assert(is_same<underlying_type<E2>::type, char>::value, "Error");
|
||||||
|
static_assert(is_same<underlying_type<E3>::type, int>::value, "Error");
|
||||||
|
static_assert(is_same<underlying_type<E4>::type,
|
||||||
|
unsigned char>::value, "Error");
|
||||||
|
static_assert(is_same<underlying_type<E5>::type, int>::value, "Error");
|
||||||
|
static_assert(is_same<underlying_type<E6>::type, long>::value, "Error");
|
||||||
|
}
|
Loading…
Reference in New Issue