Il 29/01/2011 17:07, Tommaso Cucinotta ha scritto:
Il 29/01/2011 15:54, Enrico Forestieri ha scritto:
Please, don't. It breaks compilation if size_t is typedef'd to
unsigned int.
I can also share my template-based one, that avoids code replication
and actually turns this burden over the odocstream class itself. Assuming
the latter works fine on all architectures, this one should as well :-).
Forgot to attach.
T.
Index: src/support/docstream.h
===================================================================
--- src/support/docstream.h (revisione 37365)
+++ src/support/docstream.h (copia locale)
@@ -147,11 +147,14 @@
///
otexstream & operator<<(otexstream &, char);
///
-otexstream & operator<<(otexstream &, double);
-///
-otexstream & operator<<(otexstream &, int);
-///
-otexstream & operator<<(otexstream &, unsigned int);
+template <class Type>
+otexstream & operator<<(otexstream & ots, Type value)
+{
+ ots.os() << value;
+ ots.canBreakLine(true);
+ ots.protectSpace(false);
+ return ots;
+}
/// Helper struct for changing stream encoding
struct SetEnc {
Index: src/support/docstream.cpp
===================================================================
--- src/support/docstream.cpp (revisione 37365)
+++ src/support/docstream.cpp (copia locale)
@@ -511,34 +511,8 @@
}
-otexstream & operator<<(otexstream & ots, double d)
-{
- ots.os() << d;
- ots.canBreakLine(true);
- ots.protectSpace(false);
- return ots;
}
-
-otexstream & operator<<(otexstream & ots, int i)
-{
- ots.os() << i;
- ots.canBreakLine(true);
- ots.protectSpace(false);
- return ots;
-}
-
-
-otexstream & operator<<(otexstream & ots, unsigned int i)
-{
- ots.os() << i;
- ots.canBreakLine(true);
- ots.protectSpace(false);
- return ots;
-}
-
-}
-
#if ! defined(USE_WCHAR_T) && defined(__GNUC__)
// We get undefined references to these virtual methods. This looks like
// a bug in gcc. The implementation here does not do anything useful, since