I came across a curious behavior in my program when compiling with the Visual Studio 2013 community, with CTP in November 2013. The following program compiles and prints "true", while the expected behavior was that it printed "false", which means GCC and clang do.
I tested this code on my installation, as well as on the following sites: http://webcompiler.cloudapp.net/ (claims the VS compiler is version 19, also prints "true"), http://codepad.org/ , http: //www.tutorialspoint.com/compile_cpp_online.php and several others.
I'm not sure what the correct behavior is, or the code is actually the correct C ++ code, so I'm completely dumb. If anyone could shed light on what is happening here, it would be fantastic.
#include <stdio.h>
#include <typeinfo>
template <typename T>
struct foo
{
template <typename U>
static void bar() {}
};
template <typename T>
void baz() {
puts(typeid(&foo<T>::template bar<int>) == typeid(int) ? "true" : "false");
}
int main() {
baz<double>();
}
Edit
Thanks to Reddit, I was able to bring this error to the STL, which reported that it had reported this, and it will be fixed in RTM VS 2015: <a4>
source
share