-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
P2985R0 A type trait for detecting virtual base classes #98310
Comments
@llvm/issue-subscribers-clang-frontend Author: Vlad Serebrennikov (Endilll)
This paper introduces `std::is_virtual_base_of` trait, and was voted into the working draft in St. Louis.
Like other traits, we're planning to support this with a `__is_virtual_base_of` builtin.
Tagging @STL, @jwakely, and @ldionne to make sure they are fine with this spelling, and hopefully to prevent implementation divergence on the name.
|
The name LGTM. For what it's worth, I would have preferred if all of the type trait builtins started with |
Name LGTM too. |
Yes, we had a similar conversation in GCC recently. That would have avoided all the problems with new built-in traits clashing with existing class templates already using the name (e.g. The suggested name seems coherent with existing practice. |
@jwakely Would it be controversial to propose that we support both the What do you think the GCC folks would say? |
I asked, and the C++ maintainers would be happy with that direction. |
I prefer the |
My thinking was to support both spellings for existing traits only, and introduce new traits as In that case, it looks like we can start right away and this trait should probably be spelled |
Thanks! I think that's a reasonable approach. |
Given that the decision to use |
|
Technically we can still change |
GCC already defines |
Thank you for letting us know. This is strong enough argument to keep |
This seems to be the consensus anyway, but I think we should simply adopt the new |
This patch adds compiler support for [P2985R0](https://wg21.link/p2985r0) "A type trait for detecting virtual base classes". Like we recently did with `__is_layout_compatible()` and `__is_pointer_interconvertible_base_of()`, we support it only in C++ mode, and reject VLAs. Resolves #98310.
P2985R0 (C++26) introduces std::is_virtual_base_of; this is the compiler builtin that will back up the library trait (which strictly requires compiler support). The name has been chosen to match LLVM/MSVC's, as per the discussion here: llvm/llvm-project#98310 The actual user-facing type trait in libstdc++ will be added later. gcc/cp/ChangeLog: * constraint.cc (diagnose_trait_expr): New diagnostic. * cp-trait.def (IS_VIRTUAL_BASE_OF): New builtin. * cp-tree.h (enum base_access_flags): Add a new flag to be able to request a search for a virtual base class. * cxx-pretty-print.cc (pp_cxx_userdef_literal): Update the list of GNU extensions to the grammar. * search.cc (struct lookup_base_data_s): Add a field to request searching for a virtual base class. (dfs_lookup_base): Add the ability to look for a virtual base class. (lookup_base): Forward the flag to dfs_lookup_base. * semantics.cc (trait_expr_value): Implement the builtin by calling lookup_base with the new flag. (finish_trait_expr): Handle the new builtin. gcc/ChangeLog: * doc/extend.texi: Document the new __builtin_is_virtual_base_of builtin; amend the docs for __is_base_of. gcc/testsuite/ChangeLog: * g++.dg/ext/is_virtual_base_of.C: New test. * g++.dg/ext/is_virtual_base_of_diagnostic.C: New test. Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Jason Merrill <jason@redhat.com>
This paper introduces
std::is_virtual_base_of
trait, and was voted into the working draft in St. Louis.Like other traits, we're planning to support this with a
__is_virtual_base_of
builtin.Tagging @stl, @jwakely, and @ldionne to make sure they are fine with this spelling, and hopefully to prevent implementation divergence on the name.
The text was updated successfully, but these errors were encountered: