0

I have the following code in myclass.h file:

typedef std::unordered_set< int, int> Parameters;
class MyClass
{
    public:
        void myFunction();
    private:
        Parameters* m_params;
}

Then, myFunction looks as follows:

void MyClass::myFunction()
{
    ...
    m_params->emplace(1,1);
}

When I try to compile, I get:

term does not evaluate to a function taking 1 arguments

If I comment the emplace line, the error disappears. However, I don't find any misuse related to this function signature: http://en.cppreference.com/w/cpp/container/unordered_map/emplace

Any help would be much appreciated.

omniyo
  • 330
  • 2
  • 6
  • 19

1 Answers1

1

Simple typo: You used std::unordered_set in your code, but you meant std::unordered_map.

Your implementation doesn't recognise any error setting Hash to int in the std::unordered_set template until you try to put something into the container. Then it tries to hash the input, and realises it can't use an int as a function.

BoBTFish
  • 19,167
  • 3
  • 49
  • 76
  • Time to take a break then! Likely you will make an error that the compiler won't save you from, and will bite you in the arse later. – BoBTFish Mar 01 '16 at 16:04