MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / computeDistance

Method computeDistance

src/jsoncpp.cpp:2288–2314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2286}
2287
2288ValueIteratorBase::difference_type
2289ValueIteratorBase::computeDistance(const SelfType& other) const {
2290#ifdef JSON_USE_CPPTL_SMALLMAP
2291 return other.current_ - current_;
2292#else
2293 // Iterator for null value are initialized using the default
2294 // constructor, which initialize current_ to the default
2295 // std::map::iterator. As begin() and end() are two instance
2296 // of the default std::map::iterator, they can not be compared.
2297 // To allow this, we handle this comparison specifically.
2298 if (isNull_ && other.isNull_) {
2299 return 0;
2300 }
2301
2302 // Usage of std::distance is not portable (does not compile with Sun Studio 12
2303 // RogueWave STL,
2304 // which is the one used by default).
2305 // Using a portable hand-made version for non random iterator instead:
2306 // return difference_type( std::distance( current_, other.current_ ) );
2307 difference_type myDistance = 0;
2308 for (Value::ObjectValues::iterator it = current_; it != other.current_;
2309 ++it) {
2310 ++myDistance;
2311 }
2312 return myDistance;
2313#endif
2314}
2315
2316bool ValueIteratorBase::isEqual(const SelfType& other) const {
2317 if (isNull_) {

Callers 1

operator-Function · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected