Lars Gullik Bjønnes wrote:
> Georg Baum <[EMAIL PROTECTED]>
> writes:
>
> | Lars,
> |
> | I get several undefined references like this one with current trunk (gcc
> | 3.3.5, 32 bit):
>
> Your gcc is too old, and to fix it we must provide the specialization
> fo char_traits<boost::uint32_t> ourselves. Gcc4 has better QoI and
> does the work for us.
This patch adds the missing bits, and the resulting executable works fine.
The question now is: where should the stuff go? I put it in docstring.h,
because it is in a header file in gcc 4.2 and docstring.h must be included
anyway if the unicode strings are used. We could as well put an explicit
specialization in a .C file (which one?).
Lars, please advise.
Georg
Index: src/support/docstring.h
===================================================================
--- src/support/docstring.h (Revision 14671)
+++ src/support/docstring.h (Arbeitskopie)
@@ -25,4 +25,57 @@ typedef std::basic_string<boost::uint32_
}
+#if defined(__GNUC__) && __GNUC__ < 4
+// Missing char_traits methods in gcc 3.x. Taken from gcc 4.2svn.
+// These are not complete, just what we use.
+namespace std {
+
+template<typename T> void
+char_traits<T>::assign(char_type & c1, char_type const & c2)
+{
+ c1 = c2;
+}
+
+
+template<typename T> bool
+char_traits<T>::eq(char_type const & c1, char_type const & c2)
+{
+ return c1 == c2;
+}
+
+
+template<typename T> std::size_t
+char_traits<T>::length(char_type const * p)
+{
+ std::size_t i = 0;
+ while (!eq(p[i], char_type()))
+ ++i;
+ return i;
+}
+
+
+template<typename T> typename char_traits<T>::char_type *
+char_traits<T>::move(char_type * s1, char_type const * s2, std::size_t n)
+{
+ return static_cast<T *>(std::memmove(s1, s2, n * sizeof(char_type)));
+}
+
+
+template<typename T> typename char_traits<T>::char_type *
+char_traits<T>::copy(char_type * s1, char_type const * s2, std::size_t n)
+{
+ std::copy(s2, s2 + n, s1);
+ return s1;
+}
+
+
+template<typename T> typename char_traits<T>::char_type *
+char_traits<T>::assign(char_type * s, std::size_t n, char_type a)
+{
+ std::fill_n(s, n, a);
+ return s;
+}
+
+}
+#endif
#endif