Is the following program compatible with C ++ 11? If so, do you know about a specific MSVC error that triggers it? and / or possible workaround?
#include <iostream> struct A {}; struct B {}; constexpr A aaa = {}; constexpr B bbb = {}; template <typename T> void foo(T, decltype(aaa)) { std::cout << "a"; } template <typename T> void foo(T, decltype(bbb)) { std::cout << "b"; } // ^ C2995 'void foo(T,unknown-type)': function template has already been defined int main() { foo(0, aaa); foo(0, bbb); }
If the actual types are replaced with decltype
, then it works, but in practice these types are too complex to reproduce, and I would prefer not to have aliases for them.
source share