Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement LWG-3823 Unnecessary precondition for is_aggregate (workaround) #3231

Merged
merged 3 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion stl/inc/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,22 @@ struct has_unique_object_representations : bool_constant<__has_unique_object_rep
_EXPORT_STD template <class _Ty>
_INLINE_VAR constexpr bool has_unique_object_representations_v = __has_unique_object_representations(_Ty);

#if 1 // TRANSITION, DevCom-10201896 and LLVM-59002
template <class _Ty>
struct _Is_aggregate_impl : bool_constant<__is_aggregate(_Ty)> {};

_EXPORT_STD template <class _Ty>
struct is_aggregate : bool_constant<__is_aggregate(_Ty)> {}; // determine whether _Ty is an aggregate
_INLINE_VAR constexpr bool is_aggregate_v = disjunction_v<is_array<_Ty>, _Is_aggregate_impl<_Ty>>;

_EXPORT_STD template <class _Ty>
struct is_aggregate : bool_constant<is_aggregate_v<_Ty>> {};
#else // ^^^ workaround / no workaround vvv
_EXPORT_STD template <class _Ty>
struct is_aggregate : bool_constant<__is_aggregate(_Ty)> {};

_EXPORT_STD template <class _Ty>
_INLINE_VAR constexpr bool is_aggregate_v = __is_aggregate(_Ty);
#endif // ^^^ no workaround ^^^
#endif // _HAS_CXX17

_EXPORT_STD template <class _Ty, class... _Args>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ STATIC_ASSERT(!is_aggregate_v<NonAggVirtualBaseFunc>);
struct NonAggVirtualBaseIndirect : NonAggVirtualBase {};
STATIC_ASSERT(!is_aggregate_v<NonAggVirtualBaseIndirect>);

struct Incomplete;

STATIC_ASSERT(is_aggregate_v<int[10]>);
STATIC_ASSERT(is_aggregate_v<int[]>);
STATIC_ASSERT(is_aggregate_v<Cxx14Agg[]>);
Expand All @@ -242,11 +244,14 @@ STATIC_ASSERT(is_aggregate_v<NonAggDefaultCtor[]>);
STATIC_ASSERT(is_aggregate_v<int* [10]>);
STATIC_ASSERT(is_aggregate_v<NonAggDefaultCtor[2][3]>);
STATIC_ASSERT(is_aggregate_v<Empty[10]>);
STATIC_ASSERT(is_aggregate_v<Incomplete[]>);
STATIC_ASSERT(is_aggregate_v<Incomplete[10]>);

STATIC_ASSERT(!is_aggregate_v<int&>);
STATIC_ASSERT(!is_aggregate_v<const int*>);
STATIC_ASSERT(!is_aggregate_v<const Cxx14Agg&>);
STATIC_ASSERT(!is_aggregate_v<Cxx14Agg*>);
STATIC_ASSERT(!is_aggregate_v<Incomplete*>);

template <typename T>
struct AggTemplateClass {
Expand Down