]> git.lyx.org Git - lyx.git/blobdiff - src/support/strfwd.h
Fix build with GNU libstdc++ C++11 ABI
[lyx.git] / src / support / strfwd.h
index f1dcb0bca925d4b75244a996ad9ce1fbfd7829b8..8419b513519b2d2d017247686fbac6169478d428 100644 (file)
@@ -28,6 +28,13 @@ namespace lyx { typedef boost::uint32_t char_type; }
 
 #endif
 
+// Forward definitions do not work with libc++
+// For gcc5 with the new std::string ABI forward declarations would work in
+// principle, but I am not sure whether we want non-standard
+// "namespace __cxx11" in our sources.
+#if defined(USE_LLVM_LIBCPP) || defined(USE_GLIBCXX_CXX11_ABI)
+#include <string>
+#else
 
 namespace std {
 
@@ -52,10 +59,15 @@ typedef basic_ostringstream<char, char_traits<char>, allocator<char> > ostringst
 
 } // namepace std
 
+#endif
 
 namespace lyx {
 
-/// String type for storing the main text in UCS4 encoding
+/**
+ * String type for storing the main text in UCS4 encoding.
+ * Use std::string only in cases 7-bit ASCII is to be manipulated
+ * within the variable.
+ */
 typedef std::basic_string<char_type, std::char_traits<char_type>,
        std::allocator<char_type> > docstring;
 
@@ -78,6 +90,15 @@ std::string const & empty_string();
 // defined in docstring.cpp
 bool operator==(docstring const &, char const *);
 
+#ifdef STD_STRING_USES_COW
+template<typename Char> class trivial_string;
+typedef trivial_string<char> trivstring;
+typedef trivial_string<char_type> trivdocstring;
+#else
+typedef std::string trivstring;
+typedef docstring trivdocstring;
+#endif
+
 } // namespace lyx
 
 #endif