A friend and I were discussing C++ templates. He asked me what this should do:
#include <iostream>
template <bool>
struct A {
A(bool) { std::cout << "bool\n"; }
A(void*) { std::cout << "void*\n"; }
};
int main() {
A<true> *d = 0;
const int b = 2;
const int c = 1;
new A< b > (c) > (d);
}
The last line in main has two reasonable parses. Is 'b' the template argument or is "b > (c)" the template argument?
Although, it is trivial to compile this, and see what we get, we were wondering what resolves the ambiguity?