// // Created by light on 20-1-5. // #include #include using namespace std; template< template class OutContainer = vector, typename F, class R> auto fmap(F &&f, R &&inputs) { typedef decay_t result_type; OutContainer> result; for (auto &&item:inputs) { result.push_back(f(item)); } return result; } // 对每一个数进行加1操作 int add_1(int x) { return x + 1; } int main() { vector v{1, 2, 3, 4, 5}; auto result = fmap(add_1, v); for (auto item:result) cout << item << " "; cout<