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.

llvm-svn: 202934
This commit is contained in:
Marshall Clow 2014-03-05 03:39:25 +00:00
parent 0ddfe7f8dc
commit 39bca1ea99
3 changed files with 63 additions and 2 deletions

View File

@ -91,6 +91,7 @@ namespace std
template <class T> struct is_empty;
template <class T> struct is_polymorphic;
template <class T> struct is_abstract;
template <class T> struct is_final; // C++14
template <class T, class... Args> struct is_constructible;
template <class T> struct is_default_constructible;
@ -759,6 +760,13 @@ template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {}
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {};
// is_final
#if __has_feature(is_final)
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
is_final : public integral_constant<bool, __is_final(_Tp)> {};
#endif
// is_base_of
#ifdef _LIBCPP_HAS_IS_BASE_OF

View File

@ -0,0 +1,53 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// type_traits
// is_final
#include <type_traits>
#if __cplusplus >= 201103L
struct P final { };
union U1 { };
union U2 final { };
template <class T>
void test_is_final()
{
static_assert( std::is_final<T>::value, "");
static_assert( std::is_final<const T>::value, "");
static_assert( std::is_final<volatile T>::value, "");
static_assert( std::is_final<const volatile T>::value, "");
}
template <class T>
void test_is_not_final()
{
static_assert(!std::is_final<T>::value, "");
static_assert(!std::is_final<const T>::value, "");
static_assert(!std::is_final<volatile T>::value, "");
static_assert(!std::is_final<const volatile T>::value, "");
}
int main ()
{
test_is_not_final<int>();
test_is_not_final<int*>();
test_is_final <P>();
test_is_not_final<P*>();
test_is_not_final<U1>();
test_is_not_final<U1*>();
test_is_final <U2>();
test_is_not_final<U2*>();
}
#else
int main () {}
#endif

View File

@ -230,7 +230,7 @@
<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>
<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>
<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>
<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>
<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>
<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>
<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 @@
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>