I have run into a corner case and looking for a work around. I am almost sure that it is a compiler bug and I couldn't come up with anything. I have a class which optionally requires a pointer to a member function. To allow it to be optional I made the default value to be nullptr. It was working until I made an unrelated change. In visual studio it now fires "invalid template argument, expected a compile-time constant". It still works in GCC. Here is the working case:
template<class Key_,
class Value_,
Key_ (Value_::*KeyFn_)() const = nullptr,
template <class ...> class Map_ = std::map>
class Hashmap { ... }
Here is the case not working
template<class Key_,
class Value_,
Key_ (Value_::*KeyFn_)() const = nullptr,
template <class ...> class Map_ = std::map,
class Comparator_=std::less<Key_>>
class Hashmap { ... }
For some reason I cannot split key retrieval from type, so even though it is tempting to supplying keyfn in constructor, it is not possible. Second version only fails if KeyFn_ is nullptr (or 0). If I give a class member for it, it compiles just fine.
Full source code is also available:
http://sourceforge.net/p/gorgon-ge/code/ci/gscript/tree/
working revision:
http://sourceforge.net/p/gorgon-ge/code/ci/77d287af75c2301fce55ab97ba49362f7ef6d9e0/tree/
I am looking either for a work around, or an explanation if it shouldn't work at all.