commit 0c0e16c61cb01555277c8605e970ace1f4fdce1b
Author: Georg Baum <[email protected]>
Date:   Tue Apr 22 22:03:31 2014 +0200

    Make iparserdocstream more like std::istream
    
    In C++98 std::istream does not use an operator bool(), but an operator
    void*() instead, which prevents some unwanted conversions (this is one
    possible implementation of the safe bool idiom).
    In C++11 std::istream uses explicit operator bool, which prevents the 
unwanted
    conversions using a new language feature.
    
    This change does not have any effect on correct code, but prevents some
    mistakes.

diff --git a/src/tex2lyx/Parser.h b/src/tex2lyx/Parser.h
index 67dd0b2..57a5cb1 100644
--- a/src/tex2lyx/Parser.h
+++ b/src/tex2lyx/Parser.h
@@ -125,10 +125,15 @@ public:
 
        iparserdocstream(idocstream & is) : is_(is) {}
 
-       /// Like std::istream::operator void*()
+#if (__cplusplus > 19971L)
+       /// Like std::istream::operator bool()
        /// Do not convert is_ implicitly to bool, since that is forbidden in 
C++11.
-       /// FIXME: Convert to operator void*() in LyX 2.2
-       operator bool() const { return s_.empty() ? !is_.fail() : true; }
+       explicit operator bool() const { return s_.empty() ? !is_.fail() : 
true; }
+#else
+       /// Like std::istream::operator void*()
+       operator void*() const { return (s_.empty() && is_.fail()) ?
+                       0 : const_cast<iparserdocstream *>(this); }
+#endif
 
        /// change the encoding of the input stream to \p e (iconv name)
        void setEncoding(std::string const & e);

Reply via email to