std:: is_pointer_interconvertible_base_of
|
ヘッダーで定義
<type_traits>
|
||
|
template
<
class
Base,
class
Derived
>
struct is_pointer_interconvertible_base_of ; |
(C++20以降) | |
Derived
が
Base
から曖昧性なく派生しており、かつすべての
Derived
オブジェクトがその
Base
部分オブジェクトと
ポインタ相互変換可能
である場合、または両方が同一の非共用体クラスである場合(いずれの場合もcv修飾を無視)、メンバ定数
value
を
true
に設定します。それ以外の場合、
value
は
false
となります。
Base
と
Derived
の両方が非共用体クラス型であり、それらが(CV修飾を無視して)同じ型でない場合、
Derived
は
完全型
でなければならない。そうでない場合、動作は未定義となる。
プログラムが
std::is_pointer_interconvertible_base_of
または
std::is_pointer_interconvertible_base_of_v
に対する特殊化を追加する場合、動作は未定義です。
目次 |
ヘルパー変数テンプレート
|
template
<
class
Base,
class
Derived
>
inline
constexpr
bool
is_pointer_interconvertible_base_of_v
=
|
(C++20以降) | |
std::integral_constantから継承
メンバ定数
|
value
[static]
|
true
の場合、
Derived
が
Base
から明確に派生しており、かつすべての
Derived
オブジェクトがその
Base
部分オブジェクトと
ポインタ相互変換可能
である場合、または両方が同じ非共用体クラスである場合(いずれの場合もCV修飾を無視)、
false
それ以外の場合
(public static member constant) |
メンバ関数
|
operator bool
|
オブジェクトを
bool
に変換し、
value
を返す
(public member function) |
|
operator()
(C++14)
|
value
を返す
(public member function) |
メンバ型
| 型 | 定義 |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
注記
std
::
is_pointer_interconvertible_base_of_v
<
T, U
>
は、
T
が
U
のprivateまたはprotected基底クラスである場合でも
true
となる可能性があります。
以下を
-
Uを完全なオブジェクト型、 -
TをU以上のcv修飾を持つ完全なオブジェクト型、 -
uをU型の任意の有効な左辺値、
reinterpret_cast < T & > ( u ) は、 std :: is_pointer_interconvertible_base_of_v < T, U > が true の場合、常に明確に定義された結果を持ちます。
T
と
U
が(CV修飾を無視して)異なる型であり、かつ
T
が
U
のポインタ相互変換可能な基底クラスである場合、
std::
is_standard_layout_v
<
T
>
と
std::
is_standard_layout_v
<
U
>
はともに
true
となります。
T
がstandard layoutクラス型の場合、
T
のすべての基底クラス(存在する場合)は
T
のpointer-interconvertible基底クラスです。
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_is_pointer_interconvertible
|
201907L
|
(C++20) |
ポインター相互変換特性:
|
例
#include <type_traits> struct Foo {}; struct Bar {}; class Baz : Foo, public Bar { int x; }; class NonStdLayout : public Baz { int y; }; static_assert(std::is_pointer_interconvertible_base_of_v<Bar, Baz>); static_assert(std::is_pointer_interconvertible_base_of_v<Foo, Baz>); static_assert(not std::is_pointer_interconvertible_base_of_v<Baz, NonStdLayout>); static_assert(std::is_pointer_interconvertible_base_of_v<NonStdLayout, NonStdLayout>); int main() {}
関連項目
|
(C++11)
|
ある型が他の型の基底型であるかどうかをチェックする
(クラステンプレート) |
|
(C++11)
|
型がクラス型(ただし共用体ではない)であり、非静的データメンバーを持たないかどうかをチェックする
(クラステンプレート) |
|
(C++11)
|
型が
スタンダードレイアウト
型であるかどうかをチェックする
(クラステンプレート) |