|
> 皆さんあんまり使われないんですかね。。。
ここは、「初心者のためのポイント学習C言語」の掲示板ですからね。
ptr_fun のサンプルプログラムを挙げればいいんでしょうか?
#include <functional> // bind1st, ptr_fun
#include <algorithm> // find_if
#include <iostream>
bool comp(const char *a, const char *b)
{
while (*a && *a == *b) a++, b++;
return !*a;
}
int main()
{
using namespace std;
char *t[] = { "alpha", "beta", "gamma", "delta", "epsilon" };
char **p = find_if(t, t+5, bind1st(ptr_fun(comp), "delta"));
if (p != t+5) cout << *p << " found\n";
}
説明が欲しいというリクエストがあれば、説明します。
|