Any TU which calls one of these functions without also #including
<{i,o}stream> will not receive a definition of the function.
Without this change, this may lead to an undefined reference error
at link time.
The standard wants us to define the functions in <string>. However,
this seems to be quite difficult due to mutual dependency issues.
The best we can do is probably to instantiate the functions here,
although this will mean that we will be nonconformant in the case
where a custom allocator is being used.
http://llvm-reviews.chandlerc.com/D1705
Files:
src/string.cpp
Index: src/string.cpp
===================================================================
--- src/string.cpp
+++ src/string.cpp
@@ -13,7 +13,9 @@
#include "cstdlib"
#include "cwchar"
#include "cerrno"
+#include "istream"
#include "limits"
+#include "ostream"
#include "stdexcept"
#ifdef _LIBCPP_MSVCRT
#include "support/win32/support.h"
@@ -527,4 +529,27 @@
{
return as_string(get_swprintf(), initial_string<wstring, long double>()(),
L"%Lf", val);
}
+
+template istream &operator>>(istream &is, string &str);
+template wistream &operator>>(wistream &is, wstring &str);
+
+template ostream &operator<<(ostream &is, const string &str);
+template wostream &operator<<(wostream &is, const wstring &str);
+
+template istream &getline(istream &is, string &str, char delim);
+template wistream &getline(wistream &is, wstring &str, wchar_t delim);
+
+template istream &getline(istream &is, string &str);
+template wistream &getline(wistream &is, wstring &str);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template istream &getline(istream &&is, string &str, char delim);
+template wistream &getline(wistream &&is, wstring &str, wchar_t delim);
+
+template istream &getline(istream &&is, string &str);
+template wistream &getline(wistream &&is, wstring &str);
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
_LIBCPP_END_NAMESPACE_STD
Index: src/string.cpp
===================================================================
--- src/string.cpp
+++ src/string.cpp
@@ -13,7 +13,9 @@
#include "cstdlib"
#include "cwchar"
#include "cerrno"
+#include "istream"
#include "limits"
+#include "ostream"
#include "stdexcept"
#ifdef _LIBCPP_MSVCRT
#include "support/win32/support.h"
@@ -527,4 +529,27 @@
{
return as_string(get_swprintf(), initial_string<wstring, long double>()(), L"%Lf", val);
}
+
+template istream &operator>>(istream &is, string &str);
+template wistream &operator>>(wistream &is, wstring &str);
+
+template ostream &operator<<(ostream &is, const string &str);
+template wostream &operator<<(wostream &is, const wstring &str);
+
+template istream &getline(istream &is, string &str, char delim);
+template wistream &getline(wistream &is, wstring &str, wchar_t delim);
+
+template istream &getline(istream &is, string &str);
+template wistream &getline(wistream &is, wstring &str);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template istream &getline(istream &&is, string &str, char delim);
+template wistream &getline(wistream &&is, wstring &str, wchar_t delim);
+
+template istream &getline(istream &&is, string &str);
+template wistream &getline(wistream &&is, wstring &str);
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
_LIBCPP_END_NAMESPACE_STD
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits