views:

157

answers:

1

Hi,

I have the following snippet:

#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)); 

}

It compile fine under

i686-apple-darwin9-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)

But under:

g++ (GCC) 3.3.3 (SuSE Linux)

It gave the following error:

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

How can I fix the problem?

+2  A: 

Why not just lognorm_dist( engine );? Providing "function-like" syntax is the whole point of operator(). That said, lognorm_dist.template operator() <boost::lagged_fibonacci44497>((engine)) should solve your compilation issues if I am not mistaken.

Logan Capaldo
just for the record :) should be noted that it is a bug in the gcc3.3 compiler: lognorm_dist in here is not dependent on template parameters. with a conforming compiler the template disambiguation is not needed. (see the sample code i put in the comments to the question)
Johannes Schaub - litb
Ahah. C++ is complicated. :)
Logan Capaldo