dimanche 3 juillet 2016

MSVC error - error C2373: 'description': redefinition; different type modifiers

#include <iostream>
#include <type_traits>


namespace MyNS {
    struct Test1 {};
    template <typename > class Test;

    template <> class Test<Test1> {
        public:
            constexpr static char const *description[] = { "X1", "Y1",};
    };
    constexpr char const *Test<Test1>::description[];
    static const char * getDesc(int i) {
        return MyNS::Test<MyNS::Test1>::description[i];
    }
}

int main()
{
    std::cout << MyNS::getDesc(0) << std::endl;
}

This fails with MSVC (error C2373: 'description': redefinition; different type modifiers), but compiles successfully on GCC 4.8.

Is there a workaround to successfully build with MSVC and GCC both?

Aucun commentaire:

Enregistrer un commentaire