[rational]boost::detail::resetter warning on MSVC7.1

While using the boost::rational MSVC7.1 generates errors saying: warning C4512: 'boost::detail::resetter' : assignment operator could not be generated So I propose following diff to boost::detail::resetter that makes this warning go away RCS file: /cvsroot/boost/boost/boost/rational.hpp,v retrieving revision 1.16 diff -u -r1.16 rational.hpp --- rational.hpp 27 Dec 2005 11:38:27 -0000 1.16 +++ rational.hpp 9 Jan 2006 16:32:12 -0000 @@ -462,11 +462,16 @@ // A utility class to reset the format flags for an istream at end // of scope, even in case of exceptions - struct resetter { + class resetter { + public: resetter(std::istream& is) : is_(is), f_(is.flags()) {} ~resetter() { is_.flags(f_); } std::istream& is_; std::istream::fmtflags f_; // old GNU c++ lib has no ios_base + private: + // MSVC 7.1 complains that he is unable to generate the assignment- + // operator so we generate it for him as to avoid the warning. + resetter& operator=(const resetter&) ; }; }

On 1/9/06 11:33 AM, "Toon Knapen" <toon.knapen@fft.be> wrote:
While using the boost::rational MSVC7.1 generates errors saying:
warning C4512: 'boost::detail::resetter' : assignment operator could not be generated
So I propose following diff to boost::detail::resetter that makes this warning go away
RCS file: /cvsroot/boost/boost/boost/rational.hpp,v retrieving revision 1.16 diff -u -r1.16 rational.hpp --- rational.hpp 27 Dec 2005 11:38:27 -0000 1.16 +++ rational.hpp 9 Jan 2006 16:32:12 -0000 @@ -462,11 +462,16 @@
// A utility class to reset the format flags for an istream at end // of scope, even in case of exceptions - struct resetter { + class resetter { + public: resetter(std::istream& is) : is_(is), f_(is.flags()) {} ~resetter() { is_.flags(f_); } std::istream& is_; std::istream::fmtflags f_; // old GNU c++ lib has no ios_base + private: + // MSVC 7.1 complains that he is unable to generate the assignment- + // operator so we generate it for him as to avoid the warning. + resetter& operator=(const resetter&) ; };
}
You could also define "is_" to be a pointer instead of a reference (and change the ctr & dtr appropriately). Then automatic copying could work just fine. Of course, you could say that copying shouldn't be allowed, then we could just inherit from boost::noncopyable instead. Finally, I added a bunch of utility classes like this many years ago (boost::rational is even older) so we could switch to that. Actually, maybe I should submit a patch to do the I/O functions for any stream (right now, they're just for istream and ostream, for use in pre-StdIO systems). -- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com
participants (2)
-
Daryle Walker
-
Toon Knapen