Pika 编程规范 #1429
Replies: 5 comments 6 replies
-
加一个
自动加到 git的 pre-commit hook脚本中 |
Beta Was this translation helpful? Give feedback.
-
Pika 发展迅速,为进一步规范 Pika 社区,提出以下几点命名规则。整体还是基于 Google Style,这里主要强调一些不同点和容易忽略的点:
|
Beta Was this translation helpful? Give feedback.
-
整体上很好。 https://github.com/google/styleguide 看看这两个 lint 是否有帮助。 |
Beta Was this translation helpful? Give feedback.
-
建议: |
Beta Was this translation helpful? Give feedback.
-
在 C++11 中已经引入 make_tuple 方便构建多返回值,pika 中以后存在多返回值时,使用 make_tuple 构建,编程示例: #include <iostream>
#include <tuple>
std::tuple<int, std::string, double> make_tuple_example() {
int a = 1;
std::string b = "hello";
double c = 3.14;
return std::make_tuple(a, b, c);
}
int main() {
std::tuple<int, std::string, double> t = make_tuple_example();
int x = std::get<0>(t); // 获取 t 中的第一个元素,即 a
std::string y = std::get<1>(t); // 获取 t 中的第二个元素,即 b
double z = std::get<2>(t); // 获取 t 中的第三个元素,即 c
std::cout << "x = " << x << std::endl;
std::cout << "y = " << y << std::endl;
std::cout << "z = " << z << std::endl;
// OR
auto xx, yy, zz = make_tuple_example();
std::cout << "x = " << xx << std::endl;
std::cout << "y = " << yy << std::endl;
std::cout << "z = " << zz << std::endl;
return 0;
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
find . -iname *.h | xargs clang-format -i
与"find . -iname *.cc | xargs clang-format -i"
把代码格式化下Beta Was this translation helpful? Give feedback.
All reactions