How to use C++20's likely/unlikely attribute in if-else statement

前端 未结 3 634
借酒劲吻你
借酒劲吻你 2020-12-05 17:23

This question is about C++20\'s [[likely]]/[[unlikely]] feature, not compiler-defined macros.

This documents (cppreference) only gave an ex

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 18:04

    Based on example from Jacksonville’18 ISO C++ Report the syntax is correct, but it seems that it is not implemented yet:

    if (a>b) [[likely]] {
    

    10.6.6 Likelihood attributes [dcl.attr.likelihood] draft

提交回复
热议问题