C++ 如何为最近的c++;版本

C++ 如何为最近的c++;版本,c++,qt,smart-pointers,ninja,meson-build,C++,Qt,Smart Pointers,Ninja,Meson Build,我最近尝试运行一个使用智能指针的代码。正如标题所说,我使用忍者(版本1.10.2)、介子(版本0.57.2)和QtCreator 4.14.2。 我有以下介子.build: project('RayTracerDemo', 'cpp', version: '0.0.0', default_options: [ 'c_std=c2x', 'cpp_std=c++20', 'warning_level=3', '

我最近尝试运行一个使用智能指针的代码。正如标题所说,我使用忍者(版本1.10.2)、介子(版本0.57.2)和QtCreator 4.14.2。 我有以下介子.build:

project('RayTracerDemo',
    'cpp',
    version: '0.0.0',
    default_options: [
        'c_std=c2x',
        'cpp_std=c++20',
        'warning_level=3',
        'optimization=3',
        'werror=true'
    ]
)

includeDir = include_directories([])

sources = files([
    'main.cpp'
])

headers = files([])

raytracer_exe = executable(
    'RayTracerDemo',
    sources: sources + headers,
    include_directories: includeDir,
    dependencies: []
)
但我仍然得到以下错误:

/~/programs/RayTracerDemo/main.cpp:189:错误:“make_unique”不是“std”的成员
../main.cpp:在函数“void render(const std::vector&)”中:
../main.cpp:189:52:错误:“make_unique”不是“std”的成员
189 |螺纹[高度*宽度+宽度]=标准::使_唯一([&]()->无效
|                                                    ^~~~~~~~~~~
../main.cpp:189:52:注意:“std::make_unique”仅在C++14之后提供
对于以下行:

threads[height*width+width]=std::make_unique([&]()->void
{
浮动xx=(2*((x+0.5)*内宽)-1)*角度*纵横比;
浮动yy=(1-2*((y+0.5)*垂直高度))*角度;
Vec3f-raydir(xx,yy,-1);
raydir.normalize();
*像素=轨迹(Vec3f(0),raydir,spheres,0);
});
作为向量的线程声明如下:

std::向量线程(高度*宽度);

Qt Creator文档说,某些功能不支持使用介子,但这不包括编译器版本问题。

看来使用介子选项一切正常,您只是忘记添加标题(是的,错误消息有点混乱):

当它与向量重叠时,不是吗

threads[invHeight * width + invWidth]  =
TL;DR 此基本代码:

#包括
#包括
int main()
{

std::cout你的编译和它的版本是什么?如果你使用cpp_std=c++14呢?我有g++(GCC)10.2.0,我已经尝试过c++14以上的所有可能的版本,包括它。我已经包括了内存。如果我没有错的话,像访问二维数组一样访问一维数组是:
array[y*x+x%y]
?编辑:我完全错了。编辑2:我的for循环很乱,谢谢你注意到,它确实不是我放的,而是
线程[y*width+x]
取而代之。@Bebel好的,那么,你解决了构建错误了吗?不幸的是,没有!我仍然得到相同的错误。我确信它来自meson/ninja/qt creator,因为当我从命令行编译时它可以工作(我仍然得到不同的错误,但那是因为我的代码错误)@bebebel然后您可以使用$meson introspect--targets build/@Babel检查所有编译器标志,如果您(重新)正确配置了生成目录$meson configure
$ meson configure <build dir>
$ meson setup --reconfigure <build dir>
threads[height * width + width]  =
threads[invHeight * width + invWidth]  =