When using clang format, how I can break the closing bracket into a new line when the line is big?

Viewed 629

So I will like to get the following code:

bool hitSphere(
  const Vec3 &center,
  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;
}

to get formatted like this by clang format:

bool hitSphere(
  const Vec3 &center,
  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;
}

Notice how before the closing bracket there is a new line now.

I read all the docs of https://clang.llvm.org/docs/ClangFormatStyleOptions.html but I could not find how to do this.

It is even posible what I want?

1 Answers
Related