Opened 15 years ago

Closed 14 years ago

#1068 closed Bugs (fixed)

Mersenne twister disables streaming for Visual C++

Reported by: s.somani@… Owned by: No-Maintainer
Milestone: To Be Determined Component: random
Version: Severity: Problem
Keywords: Cc:

Description

boost/mersenne_twister.hpp disables the streamable concept because boost config machinery says that vc 7.1/8 cannot handle member template friends. This appears not to be the case.

To work around it, I do the following:

This hack is necessary because boost thinks that Visual C++ still cannot handle member function templates It is needed to make mersenne_twister streamable #include <boost/config.hpp> #if defined(BOOST_MSVC) && defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) # undef BOOST_NO_MEMBER_TEMPLATE_FRIENDS # define FINCAD_BOOST_RNG_HACK #endif

#include <boost/random/mersenne_twister.hpp>

#ifdef FINCAD_BOOST_RNG_HACK # define BOOST_NO_MEMBER_TEMPLATE_FRIENDS # undef FINCAD_BOOST_RNG_HACK #endif

I don't know how you would fix it for the twister. It really sounds like a config machinery issue but it affects the mersenne twister code negatively.

Change History (3)

comment:1 by Richard Webb <richard.webb@…>, 15 years ago

This also seems to be the case for uniform_int - removing the

#if !defined(BOOST_NO_OPERATORS_IN_NAMESPACE) && !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)

around the streaming operators in uniform_int.hpp allows me to stream a uniform_int in and out of a std::stringstream in both VC7.1/VC8.

I haven't tried doing this with any other Random classes yet - might be worth a try to see what happens though.

comment:2 by Marshall Clow, 15 years ago

Owner: set to No-Maintainer

comment:3 by Steven Watanabe, 14 years ago

Resolution: fixed
Status: newclosed

(In [51413]) Enable stream operators on msvc. Fixes #1068. Fixes #1691

Note: See TracTickets for help on using tickets.