std::inner_productの練習
inner_productアルゴリズムの振る舞いは、
- 2個の入力範囲をとる。
- 入力範囲の各要素に対し、指定の操作(操作2)を行う。
- もう一つの操作(操作1)を行う。
サンプルプログラム
#include <algorithm>
string v1 = "abcdefg";
string v2 = "AbcDEfg";
//同じ文字の数を数える
int result = inner_product(v1.begin(), v1.end(), //入力範囲1
v2.begin(), //入力範囲2
0, //初期値
plus<int>(), //操作1
equal_to<char>()); //操作2