libc++ (http://libcxx.llvm.org/) is used on OS X with newer XCode.
The patch is from Benjamin Piwowarski <benjamin.piwowarski@lip6.fr>, I only
added more comments.
The changes regarding implicit conversion to bool of std::iostream work
because both the C++98 and C++11 standards guarantee that boolean evaluation
of streams returns !fail(). See e.g.
http://stackoverflow.com/questions/
1334858/why-dont-iostream-objects-overload-operator-bool
for details.
TempFile const tempfile("Buffer_importStringXXXXXX." + fmt->extension());
FileName const name(tempfile.name());
ofdocstream os(name.toFilesystemEncoding().c_str());
TempFile const tempfile("Buffer_importStringXXXXXX." + fmt->extension());
FileName const name(tempfile.name());
ofdocstream os(name.toFilesystemEncoding().c_str());
- bool const success = (os << contents);
+ // Do not convert os implicitly to bool, since that is forbidden in C++11.
+ bool const success = !(os << contents).fail();
os.close();
bool converted = false;
os.close();
bool converted = false;
{
idocstringstream is(charSequence(ar.begin(), ar.end()));
is >> i;
{
idocstringstream is(charSequence(ar.begin(), ar.end()));
is >> i;
+ // Do not convert is implicitly to bool, since that is forbidden in C++11.
+ return !is.fail();
{
idocstringstream is(charSequence(ar.begin(), ar.end()));
is >> d;
{
idocstringstream is(charSequence(ar.begin(), ar.end()));
is >> d;
+ // Do not convert is implicitly to bool, since that is forbidden in C++11.
+ return !is.fail();
#include "support/strfwd.h"
#include "support/strfwd.h"
+// Forward definitions do not work with libc++
+// but ios_base has already been defined in strfwd
+// if compiling with it
+#ifndef _LIBCPP_VERSION
namespace std {
class ios_base;
namespace std {
class ios_base;
typedef basic_streambuf<char, char_traits<char> > streambuf;
}
typedef basic_streambuf<char, char_traits<char> > streambuf;
}
#ifndef STRFWD_H
#define STRFWD_H
#ifndef STRFWD_H
#define STRFWD_H
+// This includes does nothing but defining _LIBCPP_VERSION
+// if libc++ is used (rather than libstdc++) - we first
+// check if we have at least a c++03 standard before
+// including the file
+#if (__cplusplus > 19971L)
+#include <ciso646>
+#endif
+
#ifdef USE_WCHAR_T
// Prefer this if possible because GNU libstdc++ has usable
#ifdef USE_WCHAR_T
// Prefer this if possible because GNU libstdc++ has usable
+// Forward definitions do not work with libc++
+#ifdef _LIBCPP_VERSION
+#include <string>
+#else
iparserdocstream(idocstream & is) : is_(is) {}
iparserdocstream(idocstream & is) : is_(is) {}
- /// Like std::istream::operator bool()
- operator bool() const { return s_.empty() ? is_ : true; }
+ /// Like std::istream::operator void*()
+ /// 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; }
/// change the encoding of the input stream to \p e (iconv name)
void setEncoding(std::string const & e);
/// change the encoding of the input stream to \p e (iconv name)
void setEncoding(std::string const & e);