support bazel complie this project and format code.

This commit is contained in:
zhangxing
2023-03-30 00:15:11 +08:00
committed by light-city
parent 1f86192576
commit 3c8a3f259b
641 changed files with 10349 additions and 9523 deletions

View File

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