I am unsure whether this is a compiler bug, or whether I have done something that goes against the standard to cause undefined behaviour. Here is my code:
#include <iostream>
template<auto InputSize, typename SizeType = decltype(InputSize)>
class StaticArray
{
public:
using size_type = SizeType;
using size_type2 = decltype(InputSize);
};
int main()
{
//StaticArray<2, int> s1;
StaticArray<2ull, int> s3;
std::cout << typeid(decltype(s3)::size_type).name() << "\t" << typeid(decltype(s3)::size_type2).name() << "\n";
return 0;
}
If the commented out line stays commented out, I get the correct output: int unsigned __int64
. However, if I uncomment the line, I get the output int int
. For reference I am compiling this in x86 debug, on MSVC 2017 v15.9.2.
s1
has nothing to do with the following lines. Has to be a bug. – Rouseauto
in templates is still an experimental feature in all compilers. So sometimes it may not work. – Branle<typeinfo>
makes this program ill-formed – Joyce