Skip to content

Commit 4e7d7cb

Browse files
committed
P2985R0 A type trait for detecting virtual base classes
1 parent 6d67d20 commit 4e7d7cb

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

source/meta.tex

Lines changed: 21 additions & 0 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>
@@ -1472,6 +1475,24 @@
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+
%FIXME: We're inconsistent about whether or not entries in this column end with a period.
1483+
without regard to cv-qualifiers. &
1484+
If \tcode{Base} and
1485+
\tcode{Derived} are non-union class types,
1486+
\tcode{Derived} shall be a complete type.
1487+
\begin{note}
1488+
Virtual base classes that are private, protected, or ambiguous
1489+
are, nonetheless, virtual base classes.
1490+
\end{note}
1491+
\begin{tailnote}
1492+
A class is never a virtual base class of itself.
1493+
\end{tailnote}
1494+
\\ \rowsep
1495+
14751496
\indexlibraryglobal{is_convertible}%
14761497
\tcode{template<class From, class To>}\br
14771498
\tcode{struct is_convertible;} &

source/support.tex

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

0 commit comments

Comments
 (0)