40 typedef std::vector<int>
Vector;
41 typedef std::equal_to<Vector::value_type> EqualTo;
43 const Vector::value_type arr [] = { 1, 2, 3, 4, 5 };
46 const Vector v1 (arr, arr +
sizeof arr /
sizeof *arr);
49 const Vector::value_type
x (3);
53 const std::binder1st<EqualTo> equal_to_3 (std::bind1st (EqualTo (),
x));
56 const Vector::const_iterator it1 =
57 std::find_if (
v1.begin (),
v1.end (), equal_to_3);
60 const Vector::const_iterator it2 =
61 std::find_if (
v1.begin (),
v1.end (), std::bind1st (EqualTo (),
x));
65 const Vector::const_iterator it3 =
66 std::find_if (
v1.begin (),
v1.end (), std::bind2nd (EqualTo (),
x));
70 const Vector::size_type
n =
71 std::count_if (
v1.begin (),
v1.end (), std::bind2nd (EqualTo (),
x));
74 std::ostream_iterator<Vector::value_type>
out (std::cout,
" ");
76 std::cout <<
"The vector { ";
77 std::copy (
v1.begin (),
v1.end (),
out);
79 std::cout <<
"} contains " <<
n <<
" element equal to " <<
x
80 <<
" at offset " << it1 -
v1.begin () <<
".\n";
83 const bool success = 1 ==
n && it1 == it2 && it1 == it2 && *it1 ==
x;
85 return success ? 0 : 1;
std::vector< UserClass, std::allocator< UserClass > > Vector