Namespaces
Variants

std:: is_pointer_interconvertible_base_of

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
헤더에 정의됨 <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-qualification을 무시할 때) 동일한 타입이 아니라면, 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 =

is_pointer_interconvertible_base_of < Base, Derived > :: value ;
(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-qualification을 갖는 완전한 객체 타입이며,
  • u U 타입의 유효한 lvalue일 때,

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 가 표준 레이아웃 클래스 타입이라면, T 의 모든 기본 클래스들(존재하는 경우)은 T 의 포인터 상호 변환 가능 기본 클래스입니다.

기능 테스트 매크로 표준 기능
__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)
타입이 클래스(단, union 제외) 타입이고 비정적 데이터 멤버가 없는지 검사합니다
(클래스 템플릿)
타입이 표준 레이아웃 타입인지 검사합니다
(클래스 템플릿)