所以我想得到下面的代码:
bool hitSphere(
const Vec3 ¢er,
double radius,
const Vec3 &origin,
const Vec3 &direction) {
Vec3 oc = origin - center;
double a = dot(direction, direction);
double b = 2.0 * dot(oc, direction);
double c = dot(oc, oc) - radius * radius;
double discriminant = b * b - 4 * a * c;
return discriminant > 0;
}
通过 clang 格式进行格式化:
bool hitSphere(
const Vec3 ¢er,
double radius,
const Vec3 &origin,
const Vec3 &direction
) {
Vec3 oc = origin - center;
double a = dot(direction, direction);
double b = 2.0 * dot(oc, direction);
double c = dot(oc, oc) - radius * radius;
double discriminant = b * b - 4 * a * c;
return discriminant > 0;
}
请注意在右括号之前有一个新行。
我阅读了 https://clang.llvm.org/docs/ClangFormatStyleOptions.html 的所有文档但我找不到如何执行此操作。
甚至可能是我想要的?
最佳答案
看起来这还不可能,但他们正在努力添加此功能
https://reviews.llvm.org/D33029
将被称为悬挂括号
https://stackoverflow.com/questions/62393608/
相关文章:
python - 如何使用 API 与 Google Colab 交互?
javascript - 使用快速服务器在 React 应用程序中热重载
html - 有条件地禁用 JQuery 日期选择器上的星期几?
xamarin - 当屏幕键盘出现在 Android 上时,xamarin 表单中的隐藏导航栏会出现
javascript - 类型注释只能在 TypeScript 文件中使用。 TS(8010)
mysql - 为什么 MySQL 8 IF 和 IFNULL 在测试值为 NULL 的变量时返回
javascript - 从用户脚本订阅 Angular 路由器事件