Hello
I am attempting to convert some code which compiles with g++ 4.4 to work with Clang31 and libc++.
The code includes <tr1/random> which exists in the g++ includes but not in libcxx/include.
libc++ does have a file <random> which does have most of the things needed but not the template class variate_generator defined like this in <tr1/random>
template<typename _Engine, typename _Dist>
class variate_generator
Is there an equivalent in libc++ or should I just import the g++ 4.4 file?
Thanks
John
P.S. The full set of defines being made in the code are:
std::tr1::mt19937 uint_gen;
std::tr1::uniform_real<double> uniform_dist;
std::tr1::variate_generator< std::tr1::mt19937, std::tr1::uniform_real<double> > uniform_gen;
std::tr1::normal_distribution<double> normal_dist;
std::tr1::variate_generator< std::tr1::mt19937, std::tr1::normal_distribution<double> > normal_gen;
You should be able to use the (presumably portable) implementation of TR1
included in Boost
http://www.boost.org/doc/libs/1_49_0/doc/html/boost_tr1/subject_list.html
The random number generation stuff seems to use Boost Random internally, which
I think it a header-only library.
best regards,
Florian Pflug
AMDG
Hello
I am attempting to convert some code which compiles with g++ 4.4 to work with Clang31 and libc++.
The code includes <tr1/random> which exists in the g++ includes but not in libcxx/include.
libc++ implements C++11, not TR1. variate_generator
didn't make it into the standard.
libc++ does have a file <random> which does have most of the things needed but not the template class variate_generator defined like this in <tr1/random>
template<typename _Engine, typename _Dist>
class variate_generator
Is there an equivalent in libc++ or should I just import the g++ 4.4 file?
Thanks
John
P.S. The full set of defines being made in the code are:
std::tr1::mt19937 uint_gen;
std::tr1::uniform_real<double> uniform_dist;
std::tr1::variate_generator< std::tr1::mt19937, std::tr1::uniform_real<double> > uniform_gen;
std::tr1::normal_distribution<double> normal_dist;
std::tr1::variate_generator< std::tr1::mt19937, std::tr1::normal_distribution<double> > normal_gen;
In Christ,
Steven Watanabe
libc++ does not implement TR1, but does have a complete implementation of C++11. In C++11 <random> is in namespace std, not std::tr1. Also variate_generator was removed from the C++11 spec in N1933 dated 2006-02-23. The rationale for this removal is in the paper and will likely more clearly explain how to modify your code than I could here. Here is a link to the paper:
Howard
Thank you all for your helpful replies.
I am using boost/tr1/random.hpp from 1.49.0 to fix the library code I am working with.
I will report the wider issues to the author of the library, who had not I think compiled it with clang.
As usual it is easy to learn new things in this community.
John