Alter-Native icon indicating copy to clipboard operation
Alter-Native copied to clipboard

Generic class in another class generates broken c++

Open zeromus opened this issue 8 years ago • 0 comments

Try this c# code

class Foo {
    class Bar<T> { }
}

It will pretty much just go off the rails, generating the below code, which among other things, references type Bar which doesn't exist.

class Foo : public virtual Object{
    public:
    class Bar_T{
        private:
        template<typename T>
        class Bar_T_Base : private virtual Object{
            public:
            Bar::Bar_Base(){
            }
        };

        private:
        template<typename T, bool>
        class Bar_T  {
        };
        private:

        //Basic types template type
        template<typename T>
        class Bar_T<T, true> : private Bar_T_Base<T>{
        };
        private:

        //Generic template type
        template<typename T>
        class Bar_T<T, false> : private virtual Bar_T_Base<Object>{
        };
    };
};

I tried a non-generic nested type and it worked OK

zeromus avatar Aug 19 '16 06:08 zeromus