+// Hack for VS6
+#if defined(_MSC_VER) && (_MSC_VER < 1310)
+#define GDCM_TYPENAME
+#else
+#define GDCM_TYPENAME typename
+#endif
+
+// Hack for Borland
+#if (defined(_MSC_VER) && (_MSC_VER < 1310)) || defined(__BORLANDC__)
+#define GDCM_TYPENAME2
+#else
+#define GDCM_TYPENAME2 typename
+#endif
+
+
+namespace GDCM_NAME_SPACE
+{
+// Long stody short: Sun compiler only provide the second interface of
+// std::distance, since the implementation is so trivial, I'd rather redo it myself.
+// Ref:
+// http://www.sgi.com/tech/stl/distance.html#2
+// The second version of distance was the one defined in the original STL, and
+// the first version is the one defined in the draft C++ standard; the definition
+// was changed because the older interface was clumsy and error-prone.
+// The older interface required the use of a temporary variable, and it has semantics
+// that are somewhat nonintuitive: it increments n by the distance from first to last,
+// rather than storing that distance in n
+ template<typename InputIterator>
+ inline int32_t
+ mydistance(InputIterator first, InputIterator last)
+ {
+ int32_t n = 0;
+ while (first != last)
+ {
+ ++first;
+ ++n;
+ }
+ return n;
+ }
+