]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-3.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / make_unsigned / requirements / typedefs-3.cc
CommitLineData
8ca1fae5 1// { dg-options "-std=gnu++11" }
2// { dg-do compile }
3
f1717362 4// Copyright (C) 2015-2016 Free Software Foundation, Inc.
8ca1fae5 5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 3, or (at your option)
10// any later version.
11//
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
20
21#include <type_traits>
22
23template<typename T, typename I0, typename... I>
24struct smallest_rank
25: std::conditional< sizeof(T) == sizeof(I0),
26 I0,
27 typename smallest_rank<T, I...>::type >
28{ };
29
30template<typename T, typename I0>
31struct smallest_rank<T, I0>
32{ using type = I0; };
33
34template<typename T>
35using smallest_rank_t
36 = typename smallest_rank<typename std::remove_cv<T>::type,
37 unsigned char, unsigned short, unsigned int,
38 unsigned long, unsigned long long>::type;
39
40using std::make_unsigned;
41using std::is_same;
42
43enum E1 : char { };
44using I1 = smallest_rank_t<E1>;
45static_assert(is_same<make_unsigned<E1>::type, I1>::value, "");
46static_assert(is_same<make_unsigned<E1 const>::type, I1 const>::value, "");
47
48enum E2 : short { };
49using I2 = smallest_rank_t<E2>;
50static_assert(is_same<make_unsigned<E2>::type, I2>::value, "");
51static_assert(is_same<make_unsigned<E2 const>::type, I2 const>::value, "");
52
53enum E3 : int { };
54using I3 = smallest_rank_t<E3>;
55static_assert(is_same<make_unsigned<E3>::type, I3>::value, "");
56static_assert(is_same<make_unsigned<E3 const>::type, I3 const>::value, "");
57
58enum E4 : long { };
59using I4 = smallest_rank_t<E4>;
60static_assert(is_same<make_unsigned<E4>::type, I4>::value, "");
61static_assert(is_same<make_unsigned<E4 const>::type, I4 const>::value, "");
62
63// PI libstdc++/60333
64enum E5 : long long { };
65using I5 = smallest_rank_t<E5>;
66static_assert(is_same<make_unsigned<E5>::type, I5>::value, "");
67static_assert(is_same<make_unsigned<E5 const>::type, I5 const>::value, "");