Home How to avoid explicit super specification when using templates in Clang?
Reply: 0

How to avoid explicit super specification when using templates in Clang?

Vojtěch Melda Meluzín
1#
Vojtěch Melda Meluzín Published in 2018-01-12 23:02:12Z

I'm using 3 compilers MSVC, Intel and Clang (on OSX, latest version I assume). Now if I use a template like this: (NOTE I edited the original code, so that the "super" is the template parameter)

template<class super> class B : public super
{
    typedef super SUPER;
public: 
    ...
    void SomeMethod1() { SomeOtherMethod(); }; // ERROR IN CLANG
    void SomeMethod2() { SUPER::SomeOtherMethod(); };
    ...
};

I'm using the SUPER thingy as it is convenient for accessing the parent class. Now the code would compile just fine in both MSVC and Intel compilers, I think I'm using C++11 here. Now in Clang the SomeMethod1 would cause an error, which would be solved by using the SUPER:: specification, but that's rather pointless, since I know there's no other way to interpret the code. It seems like it is searching the global scope unless I explicitly say "it's inside the class", while it should be the other way around. It may seem like a nitpick, but when you have a class that contains hundreds of calls to the parent, it becomes seriously annoying.

Any ideas how to avoid that? Thanks!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.353522 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO