[libc++] Implement LWG 2911 - add an is_aggregate type-trait

Summary:
This patch implements http://cplusplus.github.io/LWG/lwg-defects.html#2911.

I'm putting this up for review until __is_aggregate is added to clang (See D31513)

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D31515

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300126 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2017-04-12 23:08:46 +00:00
parent 9bd669bd90
commit 7b41c797ba
5 changed files with 133 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <type_traits>
// template <class T> struct is_aggregate;
// template <class T> constexpr bool is_aggregate_v = is_aggregate<T>::value;
#include <type_traits>
int main ()
{
#ifdef _LIBCPP_HAS_NO_IS_AGGREGATE
// This should not compile when _LIBCPP_HAS_NO_IS_AGGREGATE is defined.
bool b = __is_aggregate(void);
((void)b);
#else
#error Forcing failure...
#endif
}