Topic: Q: "ptr -> template m" ???


Author: "Paul D. DeRocco" <strip_these_words_pderocco@ix.netcom.com>
Date: 1997/04/22
Raw View

Norbert Berzen wrote:
>
> The C++ draft states that
>
>                 ptr -> template m
>
> is a syntactically correct postfix-expression. I don't
> have any idea about the semantics of the above. What does
> the keyword "template" do just behind the arrow operator?
> Could you experts explain it to me, please?

It means exactly what you'd think it would mean without the template
keyword. The keyword is necessary when m (in your example) is a template
name qualified by parameters in angle-brackets. Without it, the left
angle bracket would be interpreted as a less-than sign. I'm not sure why
this problem only crops with respect to the ->, . and :: operators, but
it probably has to do with precedence.

--

Ciao,
Paul

(Please send e-mail to mailto:pderocco@ix.netcom.com instead of the
return address, which has been altered to foil junk mail senders.)
---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: bparker@gil.com.au (Brian Parker)
Date: 1997/04/23
Raw View

Norbert Berzen <norbert@dune.gia.rwth-aachen.de> wrote:

>The C++ draft states that

>                ptr -> template m

>is a syntactically correct postfix-expression. I don't
>have any idea about the semantics of the above. What does
>the keyword "template" do just behind the arrow operator?
>Could you experts explain it to me, please?

It is needed to disambiguate a member template function call with
explicitly specified template arguments.

For example,
class A {
public:
 template<int N>
  static void func(int i);
};

...
 A::func<6>(4); // parsed as (A::func < 6) > 4;
 A::template func<6>(4); // parsed as function call

My compiler (VC++ 5.0) doesn't support this yet.

BTW an excellent description of several of the draft's newer features
is at http://www.ocsltd.com/c++/   ("C++-Beyond the ARM").

,Brian Parker (bparker@gil.com.au)


---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Norbert Berzen <norbert@dune.gia.rwth-aachen.de>
Date: 1997/04/21
Raw View

The C++ draft states that

                ptr -> template m

is a syntactically correct postfix-expression. I don't
have any idea about the semantics of the above. What does
the keyword "template" do just behind the arrow operator?
Could you experts explain it to me, please?


Apologies if this is an FAQ or if it is off topic here

Norbert

--
Norbert [norbert@dune.gia.rwth-aachen.de  (134.130.159.38)]

N. Berzen, Geod. Inst. der RWTH-Aachen, Templergraben 55, 52056 Aachen
---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]