gpt4 book ai didi

c++ - C++11 库和 g++ 4.4.7 的问题

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:35:30 25 4
gpt4 key购买 nike

我正在使用 GCC 4.4.7 版的服务器工作,不幸的是我被迫使用这个版本。我想利用 <random> C++0x 的库,但我读了 here在这个版本中 uniform_real_distribution叫做uniform_real .当我尝试调用此函数和 normal_distribution ,我没有得到有用的输出。看这个例子:

#include <random>
#include <iostream>

using namespace std;

int main()
{
typedef std::mt19937 Engine;
typedef std::uniform_real<double> Dis1;
typedef std::normal_distribution<double> Dis2;

Engine eng(0);

Dis1 dis1(0, 1);
cout << dis1(eng) << endl; //OUTPUTS 3.49921e+09

Dis2 dis2(0, 1);
cout << dis2(eng) << endl; //STALLS, NO OUTPUT

return 0;
}

我用 g++44 -std=c++0x main.cpp 编译我已经展示了我得到的输出。这里有什么问题?

最佳答案

C++11 support in gcc 4.4相当稀疏。

release notes for gcc 4.5包括

Improved experimental support for the upcoming ISO C++ standard, C++0x

特别提到<random> .

关于c++ - C++11 库和 g++ 4.4.7 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15975481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com