diff --git a/src/IndicesList.cpp b/src/IndicesList.cpp index 5f5a1fe387..644b9c8ffd 100644 --- a/src/IndicesList.cpp +++ b/src/IndicesList.cpp @@ -25,42 +25,6 @@ using namespace lyx::support; namespace lyx { -namespace { - -class IndexNamesEqual : public std::unary_function -{ -public: - IndexNamesEqual(docstring const & name) - : name_(name) - {} - - bool operator()(Index const & index) const - { - return index.index() == name_; - } -private: - docstring name_; -}; - - -class IndexHasShortcut : public std::unary_function -{ -public: - IndexHasShortcut(docstring const & shortcut) - : shortc_(shortcut) - {} - - bool operator()(Index const & index) const - { - return index.shortcut() == shortc_; - } -private: - docstring shortc_; -}; - -} // namespace - - ///////////////////////////////////////////////////////////////////// // // Index @@ -136,6 +100,16 @@ void Index::setColor(string const & str) ///////////////////////////////////////////////////////////////////// +namespace{ + +std::function IndexNamesEqual(docstring const & name) +{ + return [name](Index const & idx){ return idx.index() == name; }; +} + +} + + Index * IndicesList::find(docstring const & name) { List::iterator it = @@ -152,6 +126,16 @@ Index const * IndicesList::find(docstring const & name) const } +namespace { + +std::function IndexHasShortcut(docstring const & sc) +{ + return [sc](Index const & idx){ return idx.shortcut() == sc; }; +} + +} // namespace + + Index * IndicesList::findShortcut(docstring const & shortcut) { List::iterator it = @@ -180,9 +164,7 @@ bool IndicesList::add(docstring const & n, docstring const & s) else name = n.substr(i, j - i); // Is this name already in the list? - bool const already = - find_if(list.begin(), list.end(), - IndexNamesEqual(name)) != list.end(); + bool const already = find(name); if (!already) { added = true; Index in; @@ -230,8 +212,7 @@ bool IndicesList::rename(docstring const & oldname, { if (newname.empty()) return false; - if (find_if(list.begin(), list.end(), - IndexNamesEqual(newname)) != list.end()) + if (find(newname)) // new name already taken return false;