August 02, 2012 Converting some C++ code help. | ||||
---|---|---|---|---|
| ||||
Hi, I have the following C++ code, what would be the equivalent D code; template <class T> T Test<T>::pop(int ind) { T pop = T(); // Stuff that not important //.... return pop; } Thanks, rookie |
August 02, 2012 Re: Converting some C++ code help. | ||||
---|---|---|---|---|
| ||||
Posted in reply to rookie | On Thu, Aug 2, 2012 at 7:59 PM, rookie <rookie@rooki.com> wrote: > Hi, > > I have the following C++ code, what would be the equivalent D code; IIRC, Test<T>::pop is a method definition, right ? > > template <class T> > T Test<T>::pop(int ind) > { > T pop = T(); > // Stuff that not important > //.... > return pop; > } in D, a free function would be: T pop(T)(int ind) { T pop; return pop; } and, in a class: class Test(T) { T pop(int ind) { T pop; return pop; } } But then, my C++ is quite rusty, some I'm sure there are some gotchas that I forgot. |
Copyright © 1999-2021 by the D Language Foundation