You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
C++20 clarifies the expectation for detecting traits that cannot determine a result due to an incomplete class. However, is_base_of is expected to recognize that unions can never have a base class, nor ever be a base class, and so give the correct result - per the current working draft.
The following code is expected to compile without triggering a static assert. For the current clang/libc++, it fails to compile the middle two heterogeneous assertions:
#include <type_traits>
struct Incomplete;
union Uncomplete;
int main() {
static_assert( std::is_base_of_v<Incomplete, Incomplete>);
static_assert(!std::is_base_of_v<Incomplete, Uncomplete>); // fails to compile
static_assert(!std::is_base_of_v<Uncomplete, Incomplete>); // fails to compile
static_assert(!std::is_base_of_v<Uncomplete, Uncomplete>);
}
The text was updated successfully, but these errors were encountered:
I think we were both thinking of http://wg21.link/p1285 but it turns out not to be relevant, as that was about pointers and references to incomplete types. I believe the standard wording has required properly supporting incomplete union types in this specific trait for some time.
Extended Description
C++20 clarifies the expectation for detecting traits that cannot determine a result due to an incomplete class. However, is_base_of is expected to recognize that unions can never have a base class, nor ever be a base class, and so give the correct result - per the current working draft.
The following code is expected to compile without triggering a static assert. For the current clang/libc++, it fails to compile the middle two heterogeneous assertions:
#include <type_traits>
struct Incomplete;
union Uncomplete;
int main() {
static_assert( std::is_base_of_v<Incomplete, Incomplete>);
static_assert(!std::is_base_of_v<Incomplete, Uncomplete>); // fails to compile
static_assert(!std::is_base_of_v<Uncomplete, Incomplete>); // fails to compile
static_assert(!std::is_base_of_v<Uncomplete, Uncomplete>);
}
The text was updated successfully, but these errors were encountered: