www.digitalmars.com         C & C++   DMDScript  

c++ - Explicit Template Specification

reply John Fletcher <J.P.Fletcher aston.ac.uk> writes:
I have some code which I have used for some time with Symantec and now
DM C++.  This code has template classes with frien operators such as

template <class T>
class Complex
{
......
 public:
          friend ostream & operator<<  (ostream&, const Complex<T>&);
};

When I moved this code to gcc I found that the definition had to be
changed to

template <class T>
class Complex
{
......
 public:
          friend ostream & operator<<  <> (ostream&, const Complex<T>&);

};

for the function a template friend.  This change is a consequence (as I
understand it) of  "Explicit Template Specification".  It makes code
which used to work not work.

How is this going to be handled in the development of DM?

At the moment I have in my code things like this:

friend ostream & operator<<  TT (ostream&, const Complex<T>&);

where TT has to be given an appropriate define.

Cheers

John
Oct 10 2001
parent reply "Walter" <walter digitalmars.com> writes:
Does it no longer work with DMC?

John Fletcher wrote in message <3BC45E1C.D684997A aston.ac.uk>...
I have some code which I have used for some time with Symantec and now
DM C++.  This code has template classes with frien operators such as

template <class T>
class Complex
{
......
 public:
          friend ostream & operator<<  (ostream&, const Complex<T>&);
};

When I moved this code to gcc I found that the definition had to be
changed to

template <class T>
class Complex
{
......
 public:
          friend ostream & operator<<  <> (ostream&, const Complex<T>&);

};

for the function a template friend.  This change is a consequence (as I
understand it) of  "Explicit Template Specification".  It makes code
which used to work not work.

How is this going to be handled in the development of DM?

At the moment I have in my code things like this:

friend ostream & operator<<  TT (ostream&, const Complex<T>&);

where TT has to be given an appropriate define.

Cheers

John

Oct 10 2001
parent reply John Fletcher <J.P.Fletcher aston.ac.uk> writes:
Walter wrote:

 Does it no longer work with DMC?

How is this going to be handled in the development of DM?

At the moment I have in my code things like this:

friend ostream & operator<<  TT (ostream&, const Complex<T>&);

where TT has to be given an appropriate define.


At the moment I define TT as empty for DMC and that works. My question is, will it change? Also, the latest version of DM 8.1f does break some STL code with map and set which previously worked. John
Oct 11 2001
parent reply "Walter" <walter digitalmars.com> writes:
John Fletcher wrote in message <3BC55E8F.52955430 aston.ac.uk>...
My question is, will it change?

Over time, I intend to bring it into full conformance with C++ 98. I don't know at the moment if that means yes or no to your question <g>.
Also, the latest version of DM 8.1f does break some STL code with map and

which previously worked.

Try #defining the ARROW workaround in stl_config.h.
Oct 11 2001
parent reply John Fletcher <J.P.Fletcher aston.ac.uk> writes:
Walter wrote:

 John Fletcher wrote in message <3BC55E8F.52955430 aston.ac.uk>...
My question is, will it change?

Over time, I intend to bring it into full conformance with C++ 98. I don't know at the moment if that means yes or no to your question <g>.

O.K. I think that conformance will force you to make that change at some point. I have found in the stl_config.h a define called __STL_EXPLICIT_FUNCTION_TMPL_ARGS which if set does this: #define __STL_NULL_TMPL_ARGS <> and otherwise defines it empty. This is just the behaviour I am discussing. A quick look at other compilers shows that GCC started to define it at 2.8 and Boland switched to define it as well.
Also, the latest version of DM 8.1f does break some STL code with map and

which previously worked.

Try #defining the ARROW workaround in stl_config.h.

Got it. That fixes it so that my examples run. Thanks John
Oct 11 2001
parent reply "Walter" <walter digitalmars.com> writes:
John Fletcher wrote in message <3BC5813B.ED894AC0 aston.ac.uk>...
Got it.  That fixes it so that my examples run.

What kind of examples do you have? Are they in a form that can be incorporated into my test suite (!) and are also freely redistributable so I can legally do it? One of my problems implementing STL is a lack of self-contained test code.
Oct 11 2001
parent Jan Knepper <jan smartsoft.cc> writes:
In the SGI-STL.tar.gz is a directory SC with about 18 test programs...
I do not know if you got those already?!

Jan



Walter wrote:

 John Fletcher wrote in message <3BC5813B.ED894AC0 aston.ac.uk>...
Got it.  That fixes it so that my examples run.

What kind of examples do you have? Are they in a form that can be incorporated into my test suite (!) and are also freely redistributable so I can legally do it? One of my problems implementing STL is a lack of self-contained test code.

Oct 11 2001