[meta.member] (original) (raw)
21 Metaprogramming library [meta]
21.3 Metaprogramming and type traits [type.traits]
21.3.10 Member relationships [meta.member]
template<class S, class M> constexpr bool is_pointer_interconvertible_with_class(M S::*m) noexcept;
Mandates: S is a complete type.
Returns: true if and only ifS is a standard-layout type,M is an object type,m is not null, and each object s of type S is pointer-interconvertible ([basic.compound]) with its subobject s.*m.
template<class S1, class S2, class M1, class M2> constexpr bool is_corresponding_member(M1 S1::*m1, M2 S2::*m2) noexcept;
Mandates: S1 and S2 are complete types.
Returns: true if and only ifS1 and S2 are standard-layout struct ([class.prop]) types,M1 and M2 are object types,m1 and m2 are not null, and m1 and m2 point to corresponding members of the common initial sequence ([class.mem]) of S1 and S2.
[Note 1:
The type of a pointer-to-member expression &C::bis not always a pointer to member of C, leading to potentially surprising results when using these functions in conjunction with inheritance.
[Example 1: struct A { int a; }; struct B { int b; }; struct C: public A, public B { }; static_assert( is_pointer_interconvertible_with_class( &C::b ) );static_assert( is_pointer_interconvertible_with_class<C>( &C::b ) );static_assert( is_corresponding_member( &C::a, &C::b ) );static_assert( is_corresponding_member<C, C>( &C::a, &C::b ) ); — _end example_]
— _end note_]