fixed parens and tabs

This commit is contained in:
Frank B. Brokken 2015-05-27 16:19:44 +02:00
parent ab45ea1306
commit 2f0414d13a
4 changed files with 8 additions and 8 deletions

View file

@ -32,7 +32,7 @@ int main()
[&](auto const &str)
{
return not stringcasecmp(str, target);
}
);

View file

@ -27,7 +27,7 @@ strings that are equal to a string (tt(target)) in a vector of strings
(tt(vs)) (it is assumed that the required headers and tt(using namespace std)
have been specified):
verb(
count_if(vs.begin(), vs.end(), bind2nd(equal_to<string>(), target);
count_if(vs.begin(), vs.end(), bind2nd(equal_to<string>(), target));
)
In this example the function object tt(equal_to) is instantiated for
strings, receiving tt(target) as its second argument, and each of the strings
@ -137,11 +137,11 @@ tt(bind). E.g.,
using tt(bind) like this:
verb(
using namespace placeholders;
count_if(vs.begin(), vs.end(), bind(equal_to<string>(), _1, target);
count_if(vs.begin(), vs.end(), bind(equal_to<string>(), _1, target));
)
Here, tt(bind) returns a functor expecting one argument (represented by
tt(_1) and tt(count_if) will pass the strings in tt(vs) will in sequence to
the functor returned by tt(bind). The second argument (tt(target) is embedded
tt(_1)) and tt(count_if) will pass the strings in tt(vs) will in sequence to
the functor returned by tt(bind). The second argument (tt(target)) is embedded
inside the functor's implementation, where it is passed as second argument to
the tt(equal_to<string>()) function object.

View file

@ -11,9 +11,9 @@ int main()
vector<int> vi {1, 9, 2, 8, 3, 7, 4, 6, 5};
cout << count_if(vi.begin(), vi.end(),
cout << count_if(vi.begin(), vi.end(),
bind(greater<int>(), _1, 6)) << '\n';
cout << count_if(vi.begin(), vi.end(),
cout << count_if(vi.begin(), vi.end(),
bind(greater<int>(), 6, _1)) << '\n';
}

View file

@ -16,7 +16,7 @@ int main()
vector<int> values {1, 2, 3, 4, 5};
vector<string> text {"a", "b", "c", "d", "e"};
cout <<
cout <<
accumulate(values.begin(), values.end(), 0, lambda) << '\n' <<
accumulate(text.begin(), text.end(), string(), lambda) << '\n';
}