www.digitalmars.com         C & C++   DMDScript  

D - templates and functions

reply Daniel <daniel.lincke pik-potsdam.de> writes:
Hi,

I'm trying to reimplement something like this C++ code in D:

template<Class T>
Class A {
   ...
}

template<Class T>
A<T> some_function() {
   ...
}

While I can implement the class:

class A(X) {
   ...
}

I fail with the function, due to the fact that I don't know/find the correct
syntax for this. The version

A(X) some_function() {

}

fails with the message
function declaration without return type. (Note that constructors are always
named 'this')
which is understandable. Any idea how the correct syntax is?

Thanx, daniel
Sep 08 2011
parent reply "Simen Kjaeraas" <simen.kjaras gmail.com> writes:
On Thu, 08 Sep 2011 18:52:52 +0200, Daniel <daniel.lincke pik-potsdam.de>  
wrote:

 Hi,

 I'm trying to reimplement something like this C++ code in D:

 template<Class T>
 Class A {
    ...
 }

 template<Class T>
 A<T> some_function() {
    ...
 }

 While I can implement the class:

 class A(X) {
    ...
 }

 I fail with the function, due to the fact that I don't know/find the  
 correct
 syntax for this. The version

 A(X) some_function() {

 }

 fails with the message
 function declaration without return type. (Note that constructors are  
 always
 named 'this')
 which is understandable. Any idea how the correct syntax is?

 Thanx, daniel

This newsgroup is deprecated. Please use digitalmars.D.learn instead. -- Simen
Sep 08 2011
parent Steve Teale <steve.teale britseyeview.com> writes:
Simen,

We're all deprecated sooner or later - some of us sooner than others.

One gets the feeling that there is a politburo that controls D. Could you be so
good as to publish the names of the central committee?

You sound like somebody out of Kafka - lighten up!

Steve
Sep 30 2011