我正在尝试使用bit_ceil(),我包含了<位>头,并使用std名称空间(我知道这不是一个好的做法,但我在这里这样做是为了解决这个问题)
但当我尝试使用该函数时,它只会引发一个错误 'bit_ceil' was not declared in this scope
'bit_ceil' was not declared in this scope
#include<iostream> #include <bit> using namespace std; int main () { int x = 1; x = bit_ceil(x); }
奇怪,有人知道吗?
关于这个功能的问题在互联网上很少。
它是在C++20中引入的,因此您需要在命令行中添加(如果使用GCC) -std=c++20
-std=c++20
https://godbolt.org/z/chqaYG1bf