-
Couldn't load subscription status.
- Fork 797
Open
Description
Currently, the example reads:
struct A { int a; }; // a standard-layout class
struct B { int b; }; // a standard-layout class
struct C: public A, public B { }; // not a standard-layout class
static_assert( is_pointer_interconvertible_with_class( &C::b ) );
// Succeeds because, despite its appearance, &C::b has type
// “pointer to member of B of type int''.
static_assert( is_pointer_interconvertible_with_class<C>( &C::b ) );
// Forces the use of class C, and fails.
static_assert( is_corresponding_member( &C::a, &C::b ) );
// Succeeds because, despite its appearance, &C::a and &C::b have types
// “pointer to member of A of type int'' and
// “pointer to member of B of type int'', respectively.
static_assert( is_corresponding_member<C, C>( &C::a, &C::b ) );
// Forces the use of class C, and fails.However, the failures are because is_pointer_interconvertible_with_class<C>( &C::b ) and is_corresponding_member<C, C>( &C::a, &C::b ) are themselves ill-formed, not false results. In microsoft/STL#5730, it was noticed that given int A::* or int B::* argument values and manually specification of template arguments to C, the deduction failed despite that there can be implicit conversions.
I think we can fix the example by (demo)
-static_assert( is_pointer_interconvertible_with_class<C>( &C::b ) );
- // Forces the use of class C, and fails.
+static_assert( !is_pointer_interconvertible_with_class<C, int>( &C::b ) );
+ // Forces the use of class C, and the result is false.-static_assert( is_corresponding_member<C, C>( &C::a, &C::b ) );
- // Forces the use of class C, and fails.
+static_assert( !is_corresponding_member<C, C, int, int>( &C::a, &C::b ) );
+ // Forces the use of class C, and the result is false.But I'm not sure whether this is desired. Also, do we want a CWG issue for this?
Metadata
Metadata
Assignees
Labels
No labels