Hi guys i have been trying to implement a higher order member function that takes a method that returns a boolean value. The problem i have is that because i am using a template class i am unsure how to call my method in main. I know that normally you pass the address into the function call but it is not working with classes.
Would appreciate it if anyone could help! Thanks
Dictionary.h
using Comparison = auto (Key)->bool;
bool removeIf(Comparison);
template<class Key, class Item>
bool Dictionary<Key, Item>::removeIf(Comparison compare)
{
if (compare == true)
{
std::cout << "Absent" << std::endl;
}
else
{
std::cout << "Present" << std::endl;
}
}
main.cpp
Dictionary<std::string, std::string> dict;
std::cout <<"---Dict---" << std::endl;
dict.displayDictionary();
bool (*f)(std::string) = dict.remove;
f("1");