Reputation: 203
I'm working on an assignment for my C++ programming class which involves implementing a hash map. My instructor has given us a header file that we are required to use with our hash map class. The provided header file contains the line:
typedef std::function<unsigned int(const std::string&)> HashFunction;
From my (limited) understanding of C++, this would define the type HashFunction as a std::function. However, when I compile the code, I get the errors:
./HashMap.h:46:15: error: no type named 'function' in namespace 'std'
typedef std::function<unsigned int(const std::string&)> HashFunction;
~~~~~^
./HashMap.h:46:23: error: expected member name or ';' after declaration specifiers
typedef std::function<unsigned int(const std::string&)> HashFunction;
~~~~~~~~~~~~~~~~~~~~~^
The HashMap.h file has
#include <functional>
at the top, if it matters.
Does anyone know why I'm getting these errors?
Upvotes: 4
Views: 6927
Reputation: 52519
You need a compiler with (at least partial) C++11 support. Which compiler are you using?
Upvotes: 6