From 56c0401a90dc7e74e330083d95e57fbd59ed2fbd Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Tue, 24 Nov 2009 17:43:58 +0000 Subject: [PATCH] Fixed compilation with Sun Studio 12 (avoid usage of std::distance) --- src/lib_json/json_valueiterator.inl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib_json/json_valueiterator.inl b/src/lib_json/json_valueiterator.inl index be88c28..d6cc031 100644 --- a/src/lib_json/json_valueiterator.inl +++ b/src/lib_json/json_valueiterator.inl @@ -97,7 +97,18 @@ ValueIteratorBase::computeDistance( const SelfType &other ) const { return 0; } - return difference_type( std::distance( current_, other.current_ ) ); + + + // Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL, + // which is the one used by default). + // Using a portable hand-made version for non random iterator instead: + // return difference_type( std::distance( current_, other.current_ ) ); + difference_type myDistance = 0; + for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it ) + { + ++myDistance; + } + return myDistance; # endif #else if ( isArray_ )