Skip to content

Commit

Permalink
Update ex10_24.cpp
Browse files Browse the repository at this point in the history
I think the function find_first_greater is redundant. You can simply use bind in find_if.
  • Loading branch information
clare-lsy committed Apr 10, 2016
1 parent 23f08c7 commit ff5c2a4
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions ch10/ex10_24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,11 @@ auto check_size(string const& str, size_t sz)
return str.size() < sz;
}

auto find_first_greater(vector<int> const& v, string const& str)
{
auto predicate = [&](int i){ return bind(check_size, str, i)(); };
return find_if(v.cbegin(), v.cend(), predicate);
}

int main()
{
vector<int> vec{ 0, 1, 2, 3, 4, 5, 6, 7 };
string str("123456");
auto result = find_first_greater(vec, str);
auto result = find_if(vec.begin(), vec.end(), bind(check_size, str, _1));
if (result != vec.cend())
cout << *result << endl;
else
Expand Down

0 comments on commit ff5c2a4

Please sign in to comment.