GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::is_pointer_interconvertible_with_class(3) C++ Standard Libary std::is_pointer_interconvertible_with_class(3)

std::is_pointer_interconvertible_with_class - std::is_pointer_interconvertible_with_class


Defined in header <type_traits>
template<class S, class M>
constexpr bool is_pointer_interconvertible_with_class( M S::* mp ) (since C++20)
noexcept;


Given an object s of type S, determines whether s.*mp refers to a subobject of s and
s is pointer-interconvertible with its subobject s.*mp. The program is ill-formed if
S is not a complete type.


If S is not a StandardLayoutType, or M is not an object type, or mp is equal to
nullptr, the result is always false.


mp - a pointer-to-member to detect


true if s.*mp refers a subobject of s and s is pointer-interconvertible with its
subobject s.*mp, otherwise false, where s is an object of type S.


The type of a pointer-to-member expression &S::m is not always M S::*, where m is of
type M, because m may be a member inherited from a base class of S. The template
arguments can be specified in order to avoid potentially surprising results.


If there is a value mp of type M S::* such that
std::is_pointer_interconvertible_with_class(mp) == true, then
reinterpret_cast<M&>(s) has well-defined result and it refers the same subobject as
s.*mp, where s is a valid lvalue of type S.


On common platforms, the bit pattern of mp is all zero if
std::is_pointer_interconvertible_with_class(mp) == true.


Feature-test macro: __cpp_lib_is_pointer_interconvertible

// Run this code


#include <type_traits>
#include <iostream>


struct Foo { int x; };
struct Bar { int y; };


struct Baz : Foo, Bar {}; // not standard-layout


int main()
{
std::cout << std::boolalpha
<< std::is_same_v<decltype(&Baz::x), int Baz::*> << '\n'
<< std::is_pointer_interconvertible_with_class(&Baz::x) << '\n'
<< std::is_pointer_interconvertible_with_class<Baz, int>(&Baz::x) << '\n';
}


false
true
false


is_standard_layout checks if a type is a standard-layout type
(C++11) (class template)
is_member_object_pointer checks if a type is a pointer to a non-static member object
(C++11) (class template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.