Index: include/__config =================================================================== --- include/__config +++ include/__config @@ -25,8 +25,10 @@ #ifdef __GNUC__ #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) +#define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__) #else #define _GNUC_VER 0 +#define _GNUC_VER_NEW 0 #endif #define _LIBCPP_VERSION 5000 @@ -1046,8 +1048,9 @@ #define _LIBCPP_SAFE_STATIC #endif -#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 -#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF +#if !__has_builtin(__builtin_addressof) && \ + (_GNUC_VER < 700 || (!defined(__GNUC_PATCHLEVEL__) || __GNUC_PATCHLEVEL__ < 1)) +# define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF #endif #if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) @@ -1083,6 +1086,10 @@ # define _LIBCPP_HAS_NO_DEDUCTION_GUIDES #endif +#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001) +# define _LIBCPP_HAS_NO_IS_AGGREGATE +#endif + #endif // __cplusplus #endif // _LIBCPP_CONFIG Index: include/type_traits =================================================================== --- include/type_traits +++ include/type_traits @@ -97,6 +97,7 @@ template struct is_polymorphic; template struct is_abstract; template struct is_final; // C++14 + template struct is_aggregate; // C++17 template struct is_constructible; template struct is_default_constructible; @@ -286,6 +287,8 @@ = is_abstract::value; // C++17 template constexpr bool is_final_v = is_final::value; // C++17 + template constexpr bool is_aggregate_v + = is_aggregate::value; // C++17 template constexpr bool is_signed_v = is_signed::value; // C++17 template constexpr bool is_unsigned_v @@ -1325,6 +1328,19 @@ = is_final<_Tp>::value; #endif +// is_aggregate +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) + +template struct _LIBCPP_TEMPLATE_VIS +is_aggregate : public integral_constant {}; + +#if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template +constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; +#endif + +#endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) + // is_base_of #ifdef _LIBCPP_HAS_IS_BASE_OF Index: test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp =================================================================== --- /dev/null +++ test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp @@ -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 + +// + +// template struct is_aggregate; +// template constexpr bool is_aggregate_v = is_aggregate::value; + +#include + +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 +} Index: test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp =================================================================== --- /dev/null +++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// + +// template struct is_aggregate; +// template constexpr bool is_aggregate_v = is_aggregate::value; + +#include +#include "test_macros.h" + +template +void test_true() +{ +#if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) + static_assert( std::is_aggregate::value, ""); + static_assert( std::is_aggregate::value, ""); + static_assert( std::is_aggregate::value, ""); + static_assert( std::is_aggregate::value, ""); + static_assert( std::is_aggregate_v, ""); + static_assert( std::is_aggregate_v, ""); + static_assert( std::is_aggregate_v, ""); + static_assert( std::is_aggregate_v, ""); +#endif +} + +template +void test_false() +{ +#if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) + static_assert(!std::is_aggregate::value, ""); + static_assert(!std::is_aggregate::value, ""); + static_assert(!std::is_aggregate::value, ""); + static_assert(!std::is_aggregate::value, ""); + static_assert(!std::is_aggregate_v, ""); + static_assert(!std::is_aggregate_v, ""); + static_assert(!std::is_aggregate_v, ""); + static_assert(!std::is_aggregate_v, ""); +#endif +} + +struct Aggregate {}; +struct HasCons { HasCons(int); }; +struct HasPriv { + void PreventUnusedPrivateMemberWarning(); +private: + int x; +}; +struct Union { int x; void* y; }; + + +int main () +{ + { + test_false(); + test_false(); + test_false(); + test_false(); + test_false(); + test_false(); + test_false(); + test_false(); + test_false(); + } + { + test_true(); + test_true(); + test_true(); + test_true(); + } +} Index: www/cxx1z_status.html =================================================================== --- www/cxx1z_status.html +++ www/cxx1z_status.html @@ -480,7 +480,7 @@ 2904Make variant move-assignment more exception safeKona 2905is_constructible_v<unique_ptr<P, D>, P, D const &> should be false when D is not copy constructibleKona 2908The less-than operator for shared pointers could do moreKona - 2911An is_aggregate type trait is neededKona + 2911An is_aggregate type trait is neededKonaComplete 2921packaged_task and type-erased allocatorsKona 2934optional<const T> doesn't compare with TKonaComplete