代码之家  ›  专栏  ›  技术社区  ›  Abdullah Kassar

未在此作用域中声明“bit_ceil”

  •  0
  • Abdullah Kassar  · 技术社区  · 3 年前

    我正在尝试使用bit_ceil(),我包含了<位>头,并使用std名称空间(我知道这不是一个好的做法,但我在这里这样做是为了解决这个问题)

    但当我尝试使用该函数时,它只会引发一个错误 'bit_ceil' was not declared in this scope

    完整代码:

    #include<iostream>
    #include <bit>
    using namespace std;
    int main ()
    {
        int x = 1;
        x = bit_ceil(x);
    
    }
    

    奇怪,有人知道吗?

    关于这个功能的问题在互联网上很少。

    1 回复  |  直到 3 年前
        1
  •  2
  •   0___________    3 年前

    它是在C++20中引入的,因此您需要在命令行中添加(如果使用GCC) -std=c++20

    https://godbolt.org/z/chqaYG1bf

    推荐文章