#include <iostream>
#include <numeric>
#include <vector>
#define fold(a,x,f) std::accumulate(begin(a),end(a),(x),(f))
template<class T>typename T::value_type join(T const& c){typedef typename T::value_type U;return fold(c,U(),std::plus<U>());};
using namespace std;
int main() {
vector<int> a = {10, 20, 30};
vector<string> b = {"hel", "lo wo", "rld"};
cout << join(a) << endl;
cout << join(b) << endl;
cout << fold(a, 0, [](int x, int y){return x+y;}) << endl;
cout << fold(b, string(), [](string x, string y){return x+y;}) << endl;
return 0;
}