gpt4 book ai didi

c++ - 在 Boost 中的 GCC 3.3 问题下使用 operator() 进行编译

转载 作者:行者123 更新时间:2023-11-28 04:00:59 24 4
gpt4 key购买 nike

我有以下片段:

#include <boost/random/lognormal_distribution.hpp>
#include <boost/random/lagged_fibonacci.hpp>

int main() {

const double mean = 0.0;
const double sigma = 1.0;

boost::lognormal_distribution<double> lognorm_dist(mean, sigma);
boost::lagged_fibonacci44497 engine;

// the following line give error in GCC 3.3
const double value = lognorm_dist.operator() <boost::lagged_fibonacci44497>((engine));

}

下编译正常
i686-apple-darwin9-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)

但在:

g++ (GCC) 3.3.3 (SuSE Linux)

它给出了以下错误:

Mycode.cc:10:error: `operator()' not defined

我该如何解决这个问题?

最佳答案

为什么不只是 lognorm_dist( engine ); ?提供“类似函数”的语法是 operator() 的重点。也就是说,lognorm_dist.template operator() <boost::lagged_fibonacci44497>((engine))如果我没记错的话应该可以解决你的编译问题。

关于c++ - 在 Boost 中的 GCC 3.3 问题下使用 operator() 进行编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/576325/

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