I'm trying to see if my map already contains a class of "Bar' in it's keys:
1 2 3 4 5 6 7 8 9 10
|
//Foo.h
map <Bar, int> inventory;
//Foo.cpp
bool Foo::CheckIfItemExists(Inventory& _inventory, Bar bar)
{
map<Bar, int>::iterator it = _inventory.inventory.find(bar);
if (it != inventory.inventory.end()){return true;}
return false;
}
|
I'm getting:
binary '<': no operator found which takes a left-hand operand of type 'const Bar' (or there is no acceptable conversion).
Last edited on
map already contains a class of "Bar' in it's keys: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
# include <iostream>
# include <map>
# include <type_traits>
# include <iomanip>
struct Bar{};
int main()
{
std::map<Bar, int>::key_type key;
std::cout << std::boolalpha << std::is_same<decltype(key), int> :: value << "\n"
<< std::is_same<decltype(key), Bar> :: value << "\n";
}
|
Last edited on