🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #4067

Better template syntax?

#4067
From: Roman Lechtchinsky
Date: Tue, 16 Apr 1996 22:30
36 lines
2135 bytes
Hi, 

sorry for being curious but I'm only human... My question is: when declaring 
templates, why isn't it required to declare what one expects of the 
template's parameters? Let's create a template function:

template<class T> bool equal( const T& t1, const T& t2 )
{
  return t1==t2;
}

Now, personally I would prefer to write something like:

template<class T { bool operator==( const T& t ) const; }> ...

This would make both the development and the use of templates much easier ( 
to me, at least ). No need for writing lots of comments explaining what 
interface T should provide; no need for reading the source code of "equal" if 
it is part of a third-party library with poor interface documentation; no 
need to worry about implicit conversions - sounds like a lot of advantages. 
Then again, I imagine that this approach would make templates more efficient 
and easier to implement.
Now, what I'd like to know is if something like this has been considered and 
rejected ( and why ) and what other people think about it ( would this be 
really easier to use in practice; do you consider it more elegant than the 
current approach ). Thanks in advance.

Bye

Roman
---
[ 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                             ]
Technical Details
Message-ID: <31741E6C.53CA@cs.tu-berlin.de>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back

Show Full Headers
Complete Article Headers
From: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
Message-ID: <31741E6C.53CA@cs.tu-berlin.de>
X-Original-Date: Wed, 17 Apr 1996 00:25:48 +0200
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 16 Apr 96 22:30:13 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Better template syntax?
Organization: Technical University of Berlin
X-Mailer: Mozilla 2.0 (Win95; I)
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMXQff+EDnX0m9pzZAQH2kAF+OKJMY8/Zr4672SGlnjVYOMbxAssXoB9V
 tjINoon9wMSx5AZgK7CmWgpL515bAmNX
 =c3xG