Skip to content

Latest commit

 

History

History
16 lines (13 loc) · 345 Bytes

File metadata and controls

16 lines (13 loc) · 345 Bytes

Likely and Unlikely attribute

Back{: .button#cpp}

In C++20 [[unlikely]], [[likely]] attributes can be applied to statements, they allow the compiler to paths of execution

double pow(double a, int b) {
  if (n > 0) [[likely]] {
    return x * pow(a, b - 1);
  }
  else [[unlikely]] {
    return 1;
  }
}