-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathis_final.cpp
154 lines (126 loc) · 4.86 KB
/
is_final.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// $HOME/bin/bin/g++ -std=c++14 -o is_final is_final.cpp
#include<type_traits>
#include<iostream>
namespace std
{
#define __cpp_lib_is_final 201402L
/// is_final
template<typename _Tp>
struct is_final
: public integral_constant<bool, __is_final(_Tp)>
{ };
/// is_final
template<bool>
struct __is_final_helper
: public false_type { };
template<>
struct __is_final_helper<true>
: public true_type { };
//template<typename _Tp>
// struct is_final
// : public __is_final_helper<__is_final(typename remove_cv<_Tp>::type)>::type
// { };
}
class C1 {};
class C2 : C1 {};
class Cn final : C2 {};
int
main()
{
std::cout << "std::is_final<C1>::value = " << std::is_final<C1>::value << '\n';
std::cout << "std::is_final<C2>::value = " << std::is_final<C2>::value << '\n';
std::cout << "std::is_final<Cn>::value = " << std::is_final<Cn>::value << '\n';
}
/* I've got a patch in gcc_git
I need to resyc git.
Also the N4051 branch can be removed because that's in.
//--------------------- 20_util/is_final/value.cc ----------------------//
// { 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), "");
}
//--------------------- 20_util/is_final/value.cc ----------------------//
//--------------------- 20_util/is_final/requirements/explicit_instantiation.cc ----------------------//
// { 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>;
}
//--------------------- 20_util/is_final/requirements/explicit_instantiation.cc ----------------------//
//--------------------- 20_util/is_final/requirements/typedefs.cc ----------------------//
// { 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;
}
//--------------------- 20_util/is_final/requirements/typedefs.cc ----------------------//
*/