Return type depends on his argument's template
Simen Kjaeraas
simen.kjaras at gmail.com
Sat Jul 5 02:34:29 PDT 2008
TSalm <tsalm at free.fr> wrote:
> Hello,
>
> Is there a way to do this :
>
> /* ------------------------------------- */
> class A(T)
> {
> // some methods
> }
>
> class B
> {
> T getValue( A(T) a ) // <-- Here, the type of the return value
> // is the type T of A(T)
> { /* some code */ }
> }
> /* ------------------------------------- */
>
>
> thanks in advance,
> TSalm
If I understand you correctly, this can be done like so:
class A(T)
{
}
class B
{
T getValue(U : A!(T), T)(U a)
{
// some code
}
}
-- Simen
More information about the Digitalmars-d-learn
mailing list