Template functions, can we make it more simple?
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Aug 2 16:29:39 PDT 2013
On Sat, Aug 03, 2013 at 01:20:02AM +0200, SteveGuo wrote:
>
> > class A
> > {
> > auto b(auto c) { ... }
> > }
> >
> >What are the template parameters of A?
>
> class A
> {
> void foo(auto x) { ... }
> }
>
> int main()
> {
> scope a = new A;
>
> a.foo(1); // this means A has a member function "void foo(int x)
> {...}"
> a.foo(1.1); // this means A has another member function "void
> foo(double x) {...}"
> // compiler will automatically build two versions of function
> "foo"
> }
How would you translate this to the new syntax:
class A(T,U)
{
T fun1(U x) { ... }
U fun2(T x) { ... }
V fun3(V)(V x) { ... }
auto fun4(T)(T x) { ... }
auto fun5(V)(T x, V y) { ... }
const(T) fun6(T x) { ... }
T p;
T q;
U r;
U s;
}
?
T
--
The easy way is the wrong way, and the hard way is the stupid way. Pick one.
More information about the Digitalmars-d
mailing list