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

Commit

Permalink
Implement LWG #2212: std::is_final. This requires compiler support, w…
Browse files Browse the repository at this point in the history
…hich 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
  • Loading branch information
mclow committed Mar 5, 2014
1 parent 23ef151 commit ebd6c2b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
8 changes: 8 additions & 0 deletions include/type_traits
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
53 changes: 53 additions & 0 deletions test/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp
@@ -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
4 changes: 2 additions & 2 deletions www/cxx1y_status.html
Expand Up @@ -230,7 +230,7 @@ <h3>Library Working group Issues Status</h3>

<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>
Expand All @@ -255,7 +255,7 @@ <h3>Library Working group Issues Status</h3>
<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>
Expand Down

0 comments on commit ebd6c2b

Please sign in to comment.