Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22459

Why class template below compile in Visual Studio 2019 and does not with gcc 8.3?

$
0
0

Why code below compile in Visual Studio 2019 and does not with gcc 8.3?

#include<array>
template<typename T> class myClass {
public:
template<unsigned int N> myClass(const std::array<T, N>& elems) { /* do something */ }
};

int main() {
    std::array<int, 10> A;
    myClass<int> Tabular(A);
}

This is a snippet I extract from my student's project because it looks weird to me. I try this with gcc 8.3 and as I suspect the compiler complains that template argument deduction is failed. So I told my student that this does not work. But he argued that this do compile in VS without warning, I checked and he was right.

Because I'm very far from calling myself an expert, I cannot explain to myself and my student whether/why/what is wrong.


Viewing all articles
Browse latest Browse all 22459

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>