Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit ebd6c2b

Browse files
committed
Implement LWG #2212: std::is_final. This requires compiler support, which modern versions of clang provide. Also mark LWG #2230 as complete - no code changes needed.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@202934 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 23ef151 commit ebd6c2b

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

include/type_traits

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ namespace std
9191
template <class T> struct is_empty;
9292
template <class T> struct is_polymorphic;
9393
template <class T> struct is_abstract;
94+
template <class T> struct is_final; // C++14
9495
9596
template <class T, class... Args> struct is_constructible;
9697
template <class T> struct is_default_constructible;
@@ -759,6 +760,13 @@ template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {}
759760

760761
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
761762

763+
// is_final
764+
765+
#if __has_feature(is_final)
766+
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
767+
is_final : public integral_constant<bool, __is_final(_Tp)> {};
768+
#endif
769+
762770
// is_base_of
763771

764772
#ifdef _LIBCPP_HAS_IS_BASE_OF
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is dual licensed under the MIT and the University of Illinois Open
6+
// Source Licenses. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
// type_traits
11+
12+
// is_final
13+
14+
#include <type_traits>
15+
16+
#if __cplusplus >= 201103L
17+
18+
struct P final { };
19+
union U1 { };
20+
union U2 final { };
21+
22+
template <class T>
23+
void test_is_final()
24+
{
25+
static_assert( std::is_final<T>::value, "");
26+
static_assert( std::is_final<const T>::value, "");
27+
static_assert( std::is_final<volatile T>::value, "");
28+
static_assert( std::is_final<const volatile T>::value, "");
29+
}
30+
31+
template <class T>
32+
void test_is_not_final()
33+
{
34+
static_assert(!std::is_final<T>::value, "");
35+
static_assert(!std::is_final<const T>::value, "");
36+
static_assert(!std::is_final<volatile T>::value, "");
37+
static_assert(!std::is_final<const volatile T>::value, "");
38+
}
39+
40+
int main ()
41+
{
42+
test_is_not_final<int>();
43+
test_is_not_final<int*>();
44+
test_is_final <P>();
45+
test_is_not_final<P*>();
46+
test_is_not_final<U1>();
47+
test_is_not_final<U1*>();
48+
test_is_final <U2>();
49+
test_is_not_final<U2*>();
50+
}
51+
#else
52+
int main () {}
53+
#endif

www/cxx1y_status.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ <h3>Library Working group Issues Status</h3>
230230

231231
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#1450">1450</a></td><td>Contradiction in regex_constants</td><td>Issaquah</td><td>Complete</td></tr>
232232
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2003">2003</a></td><td>String exception inconsistency in erase.</td><td>Issaquah</td><td>Complete</td></tr>
233-
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2112">2112</a></td><td>User-defined classes that cannot be derived from</td><td>Issaquah</td><td></td></tr>
233+
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2112">2112</a></td><td>User-defined classes that cannot be derived from</td><td>Issaquah</td><td>Complete</td></tr>
234234
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2132">2132</a></td><td>std::function ambiguity</td><td>Issaquah</td><td></td></tr>
235235
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2182">2182</a></td><td>Container::[const_]reference types are misleadingly specified</td><td>Issaquah</td><td>Complete</td></tr>
236236
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2188">2188</a></td><td>Reverse iterator does not fully support targets that overload operator&</td><td>Issaquah</td><td>Complete</td></tr>
@@ -255,7 +255,7 @@ <h3>Library Working group Issues Status</h3>
255255
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2323">2323</a></td><td>vector::resize(n, t)'s specification should be simplified</td><td>Issaquah</td><td>Complete</td></tr>
256256
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2324">2324</a></td><td>Insert iterator constructors should use addressof()</td><td>Issaquah</td><td>Complete</td></tr>
257257
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2329">2329</a></td><td>regex_match()/regex_search() with match_results should forbid temporary strings</td><td>Issaquah</td><td>Complete</td></tr>
258-
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2330">2330</a></td><td>regex("meow", regex::icase) is technically forbidden but should be permitted</td><td>Issaquah</td><td></td></tr>
258+
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2330">2330</a></td><td>regex("meow", regex::icase) is technically forbidden but should be permitted</td><td>Issaquah</td><td>Complete</td></tr>
259259
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2332">2332</a></td><td>regex_iterator/regex_token_iterator should forbid temporary regexes</td><td>Issaquah</td><td>Complete</td></tr>
260260
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2339">2339</a></td><td>Wording issue in nth_element</td><td>Issaquah</td><td>Complete</td></tr>
261261
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2341">2341</a></td><td>Inconsistency between basic_ostream::seekp(pos) and basic_ostream::seekp(off, dir)</td><td>Issaquah</td><td>Complete</td></tr>

0 commit comments

Comments
 (0)