diff options
author | Neil Moore <neil@s-z.org> | 2014-07-11 02:33:24 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2014-07-11 02:49:44 -0400 |
commit | 65a70f904cc3c0052d120fc36968c584bded7e84 (patch) | |
tree | 02f97f17479bc8b4b9eb689778494f353fa318f4 /crawl-ref/source/menu.cc | |
parent | 9a0c33d08245699d708f61179e2725f07f5ba877 (diff) | |
download | crawl-ref-65a70f904cc3c0052d120fc36968c584bded7e84.tar.gz crawl-ref-65a70f904cc3c0052d120fc36968c584bded7e84.zip |
Replace some function objects with functions.
This is a source code simplification only: ptr_fun still turns them into
the function objects that bind2nd needs.
Diffstat (limited to 'crawl-ref/source/menu.cc')
-rw-r--r-- | crawl-ref/source/menu.cc | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc index 1b0948b9b7..29925aa5dd 100644 --- a/crawl-ref/source/menu.cc +++ b/crawl-ref/source/menu.cc @@ -2503,22 +2503,16 @@ void PrecisionMenu::attach_object(MenuObject* item) } // Predicate for std::find_if -class _string_lookup : public binary_function<MenuObject*, string, bool> +static bool _string_lookup(MenuObject* item, string lookup) { -public: - bool operator() (MenuObject* item, string lookup) const - { - if (item->get_name().compare(lookup) == 0) - return true; - return false; - } -}; + return item->get_name().compare(lookup) == 0; +} MenuObject* PrecisionMenu::get_object_by_name(const string &search) { vector<MenuObject*>::iterator ret_val; ret_val = find_if(m_attached_objects.begin(), m_attached_objects.end(), - bind2nd(_string_lookup(), search)); + bind2nd(ptr_fun(_string_lookup), search)); if (ret_val != m_attached_objects.end()) return *ret_val; return NULL; @@ -3480,16 +3474,10 @@ MenuItem* MenuFreeform::get_active_item() } // Predicate for std::find_if -class _id_comparison : public binary_function<MenuItem*, int, bool> +static bool _id_comparison(MenuItem* item, int ID) { -public: - bool operator() (MenuItem* item, int ID) const - { - if (item->get_id() == ID) - return true; - return false; - } -}; + return item->get_id() == ID; +} /** * Sets item by ID @@ -3499,7 +3487,7 @@ void MenuFreeform ::set_active_item(int ID) { vector<MenuItem*>::iterator ret_val; ret_val = find_if(m_entries.begin(), m_entries.end(), - bind2nd(_id_comparison(), ID)); + bind2nd(ptr_fun(_id_comparison), ID)); if (ret_val != m_entries.end()) { m_active_item = *ret_val; @@ -4013,7 +4001,7 @@ void MenuScroller::set_active_item(int ID) vector<MenuItem*>::iterator ret_val; ret_val = find_if(m_entries.begin(), m_entries.end(), - bind2nd(_id_comparison(), ID)); + bind2nd(ptr_fun(_id_comparison), ID)); if (ret_val != m_entries.end()) { set_active_item(*ret_val); |