[fpc-devel] [Feature Request] get nested type from a generic class

ZAN DoYe 1123monkey at gmail.com
Thu Mar 14 08:19:35 CET 2013


On 09/21/2012 06:09 PM, ZAN DoYe wrote:
> On 2012-09-21 17:25, Sven Barth wrote:
>> In that case you must always pass the type ("keyType" in your example) to tCompOps as well. Anything else does not work. Even generic constraints would not work here.
> Eh? Fpc can specializes C.lessThan, then why can't C.keyType? Hense I request this feature :)
And, for example:

> #include <iostream>
>
> using namespace std;
>
> template<typename T>
> class tn {
>     public:
>         typedef T nt;
> };
>
> template<typename C>
> class to {
>     public:
>         void sayHi(typename C::nt w) {    // prefix a `typename' keyword before the nested type which is in a generic class C. It works in cpp.
>             cout << w << endl;
>         };
> };
>
> int main(int argc, char * argv[])
> {
>     to< tn<int>  > o;
>     o.sayHi(3);
>     return 0;
> }

could someone add this handy feature into fpc




More information about the fpc-devel mailing list