Date: Tue, 13 Jun 2023 11:59:04 -0700
On Tuesday, 13 June 2023 10:59:47 PDT Arthur O'Dwyer wrote:
> Thiago (or anyone), if you went with the +/- syntax, how would you prefer to
> spell the "array element subobject" and "base subobject" transformations I
> mentioned? Is there a natural syntax for those?
You could do the unsafe solution and assume that the pointer points to an
element in the array and just allow modifying it like regular pointers:
struct S { int i[4]; };
int S::*pmarray = &S::i;
int S::*pmsecond = pmarray + 1;
because after all you could do:
struct S s;
int *array = pmarray + &s;
int *second = array + 1;
int S:: *pmsecond = second - &s;
// pmsecond = pmarray + &s + 1 - &s
// pmsecond = pmarray + 1
> Thiago (or anyone), if you went with the +/- syntax, how would you prefer to
> spell the "array element subobject" and "base subobject" transformations I
> mentioned? Is there a natural syntax for those?
You could do the unsafe solution and assume that the pointer points to an
element in the array and just allow modifying it like regular pointers:
struct S { int i[4]; };
int S::*pmarray = &S::i;
int S::*pmsecond = pmarray + 1;
because after all you could do:
struct S s;
int *array = pmarray + &s;
int *second = array + 1;
int S:: *pmsecond = second - &s;
// pmsecond = pmarray + &s + 1 - &s
// pmsecond = pmarray + 1
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DCAI Cloud Engineering
Received on 2023-06-13 18:59:06