Skip to content

Commit 4049a1a

Browse files
authored
Merge 2024-06 LWG Motion 6
P2985R0 A type trait for detecting virtual base classes
2 parents accc339 + e2833bb commit 4049a1a

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

source/meta.tex

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@
262262
// \ref{meta.rel}, type relations
263263
template<class T, class U> struct is_same;
264264
template<class Base, class Derived> struct is_base_of;
265+
template<class Base, class Derived> struct is_virtual_base_of;
265266
template<class From, class To> struct is_convertible;
266267
template<class From, class To> struct is_nothrow_convertible;
267268
template<class T, class U> struct is_layout_compatible;
@@ -548,6 +549,8 @@
548549
constexpr bool @\libglobal{is_same_v}@ = is_same<T, U>::value;
549550
template<class Base, class Derived>
550551
constexpr bool @\libglobal{is_base_of_v}@ = is_base_of<Base, Derived>::value;
552+
template<class Base, class Derived>
553+
constexpr bool @\libglobal{is_virtual_base_of_v}@ = is_virtual_base_of<Base, Derived>::value;
551554
template<class From, class To>
552555
constexpr bool @\libglobal{is_convertible_v}@ = is_convertible<From, To>::value;
553556
template<class From, class To>
@@ -1463,15 +1466,31 @@
14631466
without regard to cv-qualifiers &
14641467
If \tcode{Base} and
14651468
\tcode{Derived} are non-union class types and are
1466-
not (possibly cv-qualified versions of) the same type,
1469+
not (possibly cv-qualified versions of) the same type,
14671470
\tcode{Derived} shall be a complete
14681471
type.
14691472
\begin{tailnote}
1470-
Base classes that are private, protected, or ambiguous
1473+
Base classes that are private, protected, or ambiguous
14711474
are, nonetheless, base classes.
14721475
\end{tailnote}
14731476
\\ \rowsep
14741477

1478+
\indexlibraryglobal{is_virtual_base_of}%
1479+
\tcode{template<class Base, class Derived>}\br
1480+
\tcode{struct is_virtual_base_of;} &
1481+
\tcode{Base} is a virtual base class of \tcode{Derived}\iref{class.mi}
1482+
without regard to cv-qualifiers. &
1483+
If \tcode{Base} and
1484+
\tcode{Derived} are non-union class types,
1485+
\tcode{Derived} shall be a complete type.
1486+
\begin{note}
1487+
Virtual base classes that are private, protected, or ambiguous
1488+
are, nonetheless, virtual base classes.
1489+
\end{note}
1490+
\begin{tailnote}
1491+
A class is never a virtual base class of itself.
1492+
\end{tailnote} \\ \rowsep
1493+
14751494
\indexlibraryglobal{is_convertible}%
14761495
\tcode{template<class From, class To>}\br
14771496
\tcode{struct is_convertible;} &
@@ -1486,7 +1505,7 @@
14861505
the conversion, as defined by \tcode{is_convertible},
14871506
is known not to throw any exceptions\iref{expr.unary.noexcept} &
14881507
\tcode{From} and \tcode{To} shall be complete types,
1489-
\cv{}~\keyword{void}, or arrays of unknown bound. \\ \rowsep
1508+
\cv{}~\keyword{void}, or arrays of unknown bound. \\ \rowsep
14901509

14911510
\indexlibraryglobal{is_layout_compatible}%
14921511
\tcode{template<class T, class U>}\br

source/support.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@
700700
#define @\defnlibxname{cpp_lib_is_pointer_interconvertible}@ 201907L // freestanding, also in \libheader{type_traits}
701701
#define @\defnlibxname{cpp_lib_is_scoped_enum}@ 202011L // freestanding, also in \libheader{type_traits}
702702
#define @\defnlibxname{cpp_lib_is_swappable}@ 201603L // freestanding, also in \libheader{type_traits}
703+
#define @\defnlibxname{cpp_lib_is_virtual_base_of}@ 202406L // also in \libheader{type_traits}
703704
#define @\defnlibxname{cpp_lib_is_within_lifetime}@ 202306L // also in \libheader{type_traits}
704705
#define @\defnlibxname{cpp_lib_jthread}@ 201911L // also in \libheader{stop_token}, \libheader{thread}
705706
#define @\defnlibxname{cpp_lib_latch}@ 201907L // also in \libheader{latch}

0 commit comments

Comments
 (0)