Блог пользователя I_love_tigersugar

Автор I_love_tigersugar, история, 11 лет назад, По-английски

The easy problem in SRM 685 is the N-th time I failed because of using __builtin_popcount instead of __builtin_popcountll. As a result, a new line has been added to my template code:

#define __builtin_popcount __builtin_popcountll

Btw, does anyone have an idea why C++ doesn't merge the 2 above functions into one to avoid such silly mistakes?

  • Проголосовать: нравится
  • +24
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +19 Проголосовать: не нравится

The reason that you have 2 different functions is that, __builtin_popcount and __builtin_popcountll are defined in C. In C, unlike C++, you don't have function overloading. For example, you can't do the following in C:

int f(int a) {
}
int f(char a) {
}

Thus, you have 2 different functions. The same happened with abs, llabs, fabs..