🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

4 total messages Started by Scott Meyers Thu, 11 Apr 1996 00:06
Template Syntax
#3984
Author: Scott Meyers
Date: Thu, 11 Apr 1996 00:06
32 lines
1775 bytes
I was under the impression that the use of a template name inside the
definition of a class template was implicitly considered to be qualified
by the template parameter(s).  For example, I thought that in

  template <class T>
  class Array {
  public:
    Array operator=(const Array& rhs);
    ...
  };
  
the declaration of operator= was legal, because the use of the token
"Array" as a return type and a paramter was implicitly treated as if it
were "Array<T>." Many compilers accept this, but I'm told that several
reject it, and I can't find language in the January DWP that allows it. 

  1.  Is the above syntax valid, or must "Array" always be specified as
      "Array<T>"? 

  2.  If the above is not valid, was it valid at one time (post-ARM)?
      If so, when and why was it disallowed? 
  
Thanks,

Scott
---
[ 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 
]
Re: Template Syntax
#3990
Author: David Vandevoorde
Date: Thu, 11 Apr 1996 15:49
19 lines
1357 bytes
>>>>> "SM" == Scott Meyers <smeyers@netcom.com> writes:
[...]
SM>   1.  Is the above syntax valid, or must "Array" always be
SM> specified as "Array<T>"?

Yes, it's valid. For the January DWP this is explained in
[temp.local] 14.2.1/1 (14.5.1/1 in the Santa Cruz revision
of the templates chapter).

[...]

	Daveed


[ 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                             ]
Re: Template Syntax
#3994
Author: Rich Paul
Date: Fri, 12 Apr 1996 07:30
44 lines
2129 bytes
> the declaration of operator= was legal, because the use of the token
> "Array" as a return type and a paramter was implicitly treated as if it
> were "Array<T>." Many compilers accept this, but I'm told that several
> reject it, and I can't find language in the January DWP that allows it.
> 

As I implemented the standard string class, I learned that one 
of my compilers accepts this, while another rejects it.  
MSVC4.0 and Borland 5, respectively.  I'd suspect that it a 
recently removed language feature, but for portability, I used 
this:

template < class charT, class traits, class Allocator >
class basic_string 
{
	typedef basic_string<charT, traits, Allocator> self;

	public:
	basic_string ( const self & );
};

The only problem I haven't worked around is that I'd like to 
say:

template<class charT, class traits, class Allocator >
self operator + ( const self &lhs, const self &rhs )
{
	return self ( lhs )+= rhs;
};

Alas, since there is no scope in which to use the typedef, I'm 
stuck with spelling it out ...

Regards,
Rich

(BTW, are you Scott Meyers of More Effective C++ fame?  If so, 
great job!)
---
[ 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                             ]
Re: Template Syntax
#4060
Author: Jan Bielawski
Date: Tue, 16 Apr 1996 20:13
31 lines
2105 bytes
In article <199604102351.QAA11178@netcom15.netcom.com> Scott Meyers <smeyers@netcom.com> writes:
<I was under the impression that the use of a template name inside the
<definition of a class template was implicitly considered to be qualified
<by the template parameter(s).  For example, I thought that in
<
<  template <class T>
<  class Array {
<  public:
<    Array operator=(const Array& rhs);
<    ...
<  };
<  
<the declaration of operator= was legal, because the use of the token
<"Array" as a return type and a paramter was implicitly treated as if it
<were "Array<T>." Many compilers accept this, but I'm told that several
<reject it, and I can't find language in the January DWP that allows it. 

Doesn't section 14.2.1 ("Locally declared names") explicitly allow it?
-- 
Jan Bielawski
Molecular Simulations, Inc.   )\._.,--....,'``.         | http://www.msi.com
San Diego, CA                /,   _.. \   _\  ;`._ ,.   | ph.: (619) 458-9990
jpb@msi.com              fL `._.-(,_..'--(,_..'`-.;.'   | fax: (619) 458-0136
-- 
---
[ 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 
]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads