Topic: Pointer to member extensions


Author: sachs@fnal.gov ("David Sachs")
Date: Fri, 29 Nov 2002 19:45:42 +0000 (UTC)
Raw View
I would like to see in a future version of C++ extensions to the usage of
pointer to member items to make them more usable.

// The following example shows pm usages not in current standard
class inner
{
  public:
  int i1, i2;
};

class outer
{
  inner in;
  int ia[10];
};

int main()
{
  ...
  int outer::* pm1 = &outer::ia[1];    // Element of array
  int outer::* pm2 = &outer::in.i1;    // Member of member
  ...
  pm1++;                       // pointer to member arithmetic (within
array)
  ...
}

--
The Klingons' favorite food was named by the first Earthling to see it.


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: kon@iki.fi (Kalle Olavi Niemitalo)
Date: Sun, 1 Dec 2002 22:08:21 +0000 (UTC)
Raw View
sachs@fnal.gov ("David Sachs") writes:

>   int outer::* pm2 = &outer::in.i1;    // Member of member

Perhaps you would like pointer-to-member composition, too:

  inner outer::* pm3 = &outer::in;
  int inner::* pm4 = &inner::i1;

  int outer::* pm5 = &pm3->in;
  int outer::* pm6 = &(pm3->*pm4);
  int outer::* pm7 = &(outer::in.*pm4);

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]