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_corresponding_member(3) C++ Standard Libary std::is_corresponding_member(3)

std::is_corresponding_member - std::is_corresponding_member


Defined in header <type_traits>
template<class S1, class S2, class M1, class M2>
constexpr bool is_corresponding_member( M1 S1::* mp, M2 S2::* mq ) (since C++20)
noexcept;


Determines whether mp and mq refer corresponding members in the common initial
sequence of S1 and S2. The program is ill-formed if either S1 or S2 is an incomplete
type.


If either S1 or S2 is not a StandardLayoutType, or either M1 or M2 is not an object
type, or either mp or mq is equal to nullptr, the result is always false.


mp, mq - pointers-to-member to detect


true if mp and mq refer corresponding members in the common initial sequence of S1
and S2, otherwise false.


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.

// Run this code


#include <type_traits>
#include <iostream>


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


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


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


true
true
true
true
false


is_standard_layout checks if a type is a standard-layout type
(C++11) (class template)
is_layout_compatible checks if two types are layout-compatible
(C++20) (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.