samedi 28 janvier 2017

extern template 'inconsistent explicit instantiations'

Given

#include <vector>

// Case I: error

error C2961: 'std::vector>': inconsistent explicit instantiations, a previous explicit instantiation did not specify 'extern template'

template class std::vector<int>;
extern template class std::vector<int>;


// Case II: fine
//extern template class std::vector<int>;
//template class std::vector<int>;

// Case III: fine
//extern template class std::vector<int>;
//template class std::vector<int>;
//template class std::vector<int>;

// Case IV: fine
//extern template class std::vector<int>;
//extern template class std::vector<int>;
//template class std::vector<int>;
//template class std::vector<int>;


int main()
{

}

I build the code with VS2015 Version 4.6 and see the C2961 error. However, I don't see the error with compiler http://gcc.godbolt.org/.

Question> Is this a bug with VS2015?

Thank you

Aucun commentaire:

Enregistrer un commentaire