Topic: class member access


Author: AllanW <allan_w@my-deja.com>
Date: 2000/04/24
Raw View
  "pm" <pm@NOSPAM.net> wrote:
> I want to see a member access where the . or -> token is immediately
> followed by an _identifier_ which is then followed by the < token.
>
> That is the case that is outlined in 3.4.5 para 1.

I haven't used member templates very much, so this might not be
legal, but I think it is supposed to be:

    class X {
    public:
        template<class T>const T&get(const T&x) { return x; }
    };

    void foo() {
        X x, *y=&x;
        int i=5, j;
        float a=1.2, b;
        j = x.get<int>(i);
        b = y->get<int>(a);
    }

--
Allan_W@my-deja.com is a "Spam Magnet," never read.
Please reply in newsgroups only, sorry.


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "pm" <pm@NOSPAM.net>
Date: 2000/04/16
Raw View
Can someone read 3.4.5 and show me an example of a class  member access
expression where the . or -> token is immediately followed by a <.

which is the beginning of a class template argument list.  I have
a mental block and cannot construct that kind of example, but
I would like to look at one.



Thanks !


---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: James Kuyper <kuyper@wizard.net>
Date: 2000/04/16
Raw View
pm wrote:
>
> Can someone read 3.4.5 and show me an example of a class  member access
> expression where the . or -> token is immediately followed by a <.
>
> which is the beginning of a class template argument list.  I have
> a mental block and cannot construct that kind of example, but
> I would like to look at one.

You may have mis-read that. It says "... if the . or -> token is
imediately followed by an _identifier_ followed b6 a < ..."

 if(a.x<a.y)
  a.get<T>;

---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "pm" <pm@NOSPAM.net>
Date: 2000/04/18
Raw View
"pm" <pm@NOSPAM.net> wrote in message
news:0HHJ4.1436$zu2.3079685@news1.mia...
> Can someone read 3.4.5 and show me an example of a class  member access
> expression where the . or -> token is immediately followed by a <.
>
> which is the beginning of a class template argument list.  I have
> a mental block and cannot construct that kind of example, but
> I would like to look at one.

It looks like I was a little hasty and didn't paraphrase correctly,

I want to see a member access where the . or -> token is immediately
followed by an _identifier_ which is then followed by the < token.

That is the case that is outlined in 3.4.5 para 1.

Sorry for the confusion.



---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: pmmucci@my-deja.com
Date: 2000/04/18
Raw View
In article <38F934D5.8647899B@wizard.net>,
  James Kuyper <kuyper@wizard.net> wrote:
> pm wrote:
> >
> > Can someone read 3.4.5 and show me an example of a class  member
access
> > expression where the . or -> token is immediately followed by a <.
> >
> > which is the beginning of a class template argument list.  I have
> > a mental block and cannot construct that kind of example, but
> > I would like to look at one.
>
> You may have mis-read that. It says "... if the . or -> token is
> imediately followed by an _identifier_ followed b6 a < ..."
>
>  if(a.x<a.y)
>   a.get<T>;


Thanks for responding.

Yes, I did make a mistake in paraphrasing.

Unfortunately, I cannot write code that duplicates your example.
What I was after is the class definition that leads to a.get<T>
being legal.

I can easily create an example where < is the beginning
of a argument list. and "get" is a template member function

struct A
{
  template <class T> void get () { T t; }
};

int main ()
{
  A a;
  a.get<int> ();
}

but I cant seem to construct an example
where get is a class template.

it seems to me that 3.4.5 explicitly deals with the case
that the identifier is a class template, so then this case
must be able to arise somehow.

The reason why I would like to see this is because I write small test
programs
after each read of a particular section of the standard.  I then compile
several versions of these small programs in an attempt to call into
play the relevant ruling to test the compiler and its conformance.
This process also helps further my understanding of
a particular ruling, and sometimes offers insight into the rational
behind a ruling.  Currently, I am unable to write code that tests 3.4.5
but I am sure I am going to slap my forehead once someone
posts the simple case that I have overlooked :)

Best regards


PS I am using deja for the followup because posts
from my regular isp seem to take forever to post.





Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "Gene Bushuyev" <gbush@my-deja.com>
Date: 2000/04/18
Raw View
"pm" <pm@NOSPAM.net> wrote in message
news:0HHJ4.1436$zu2.3079685@news1.mia...
> Can someone read 3.4.5 and show me an example of a class  member access
> expression where the . or -> token is immediately followed by a <.
>
> which is the beginning of a class template argument list.  I have
> a mental block and cannot construct that kind of example, but
> I would like to look at one.


That's not possible and 3.4.5 doesn't tell otherwise. It says, "if the .
or -> token is immediately followed by an identifier followed by a <"
There must be an identifier.
--
Gene Bushuyev
*** If Linux is the answer, then what is the question? ***



---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]