Topic: Templates as parameters of thier own methods
Author: "Skip Sailors" <rsailors@wyoming.com>
Date: 1997/12/29 Raw View
Suppose:
template <class T>
class X {
public:
X(const X &);
};
or should it be
template <class T>
class X {
public:
X(const X<T> &);
};
and should my complying compiler complain about something in either case? My
VC++ 5.0 compiler is being silent either way, and I don't know what to
think.
TIA
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: Oleg Zabluda <zabluda@math.psu.edu>
Date: 1997/12/30 Raw View
Skip Sailors <rsailors@wyoming.com> wrote:
: Suppose:
: template <class T>
: class X {
: public:
: X(const X &);
: };
: or should it be
: template <class T>
: class X {
: public:
: X(const X<T> &);
: };
: and should my complying compiler complain about something in either case? My
: VC++ 5.0 compiler is being silent either way, and I don't know what to
: think.
Both ways are fine and are indentical.
Oleg.
--
Life is a sexually transmitted, 100% lethal disease.
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: bzinger@iName.com (Michael Benzinger)
Date: 1997/12/31 Raw View
Skip,
What happens when you actually instantiate the template with a type?
Do compiler errors creep in? Usually in MSVC 5.0, if the template
definition is syntactically correct, it will compile without a peep.
On the otherhand, when a type is given and the template class is
actually put to use, errors are then generated.
Mike Benzinger
On 29 Dec 1997 09:37:44 PST, "Skip Sailors" <rsailors@wyoming.com>
wrote:
>Suppose:
>
> template <class T>
> class X {
> public:
> X(const X &);
> };
>
>or should it be
>
> template <class T>
> class X {
> public:
> X(const X<T> &);
> };
>
>and should my complying compiler complain about something in either case? My
>VC++ 5.0 compiler is being silent either way, and I don't know what to
>think.
---
[ 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: rsailors@wyoming.com (Robert Sailors)
Date: 1997/12/31 Raw View
Michael Benzinger [SMTP:bzinger@iName.com] replied:
> What happens when you actually instantiate the template with a type?
What happened was, I was testing the program with the debugger,
wondering why it was crashing when it executed a certain section of
code.
The parameter I was using to instantiate the template was a
medium-complex class resembling, but not derived from the MS
COleVariant.
The symptom of the huge problem is that some exception of type (...) is
caught. I have tried catching our own family of exception types,
CException *, std::exception, and I can't think of another type of
exception to catch. I continue to catch (...)
I accidentally noticed that in the templates we were writing there were
cases where template parameters used in class template function
signatures were both parameterized and unparameterized. My compiler
compiled and _linked_ with nary a peep. This may not be The Bug but I
am thinking it is _a_ bug.
I began to suspect that my understanding of the class template syntax
was weak. I looked at the FAQ and saw an example where parameters were
used. Then I spied a guy on a newsgroup who claimed that such use of
parameters was at least redundant and possibly incorrect, according to
the ISO draft.
So I looked in the ISO draft, and I couldn't find any references to my
specific situation. But there's a lot in there, and I probably missed
it.
So, what I'm looking for is a language lawyer to tell me what the Right
Way is, and to provide chapter and verse of the ISO, so that I know he's
not a guru-wannabe.
Thanks for the interest.
---
[ 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 ]