Pointer to member function template parameter in Visual Studio 2013
I came across a corner case and was looking for a job. I'm pretty sure this is a compiler error and I couldn't think of anything. I have a class that does not necessarily require a pointer to a member function. To make it optional, I made the default nullptr. It worked until I made unrelated changes. Visual studio now runs "Invalid template argument, expected compile-time constant". He still works for GCC. Here's an example:
template<class Key_,
class Value_,
Key_ (Value_::*KeyFn_)() const = nullptr,
template <class ...> class Map_ = std::map>
class Hashmap { ... }
Doesn't work here
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 break extracting keys from a type, so despite the temptation to provide keyfn in the constructor, this is not possible. The second version fails if KeyFn_ is nullptr (or 0). If I give a class member for it, it just compiles.
The complete 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'm looking for either a job or an explanation if it shouldn't work at all.
source to share
No one has answered this question yet
Check out similar questions: