CoinDistance.hpp
Go to the documentation of this file.
1 /* $Id: CoinDistance.hpp 1215 2009-11-05 11:03:04Z forrest $ */
2 // Copyright (C) 2000, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 #ifndef CoinDistance_H
5 #define CoinDistance_H
6 
7 #include <iterator>
8 
9 //-------------------------------------------------------------------
10 //
11 // Attempt to provide an std::distance function
12 // that will work on multiple platforms
13 //
14 //-------------------------------------------------------------------
15 
21 template <class ForwardIterator, class Distance>
22 void coinDistance(ForwardIterator first, ForwardIterator last,
23  Distance& n)
24 {
25 #if defined(__SUNPRO_CC)
26  n = 0;
27  std::distance(first,last,n);
28 #else
29  n = std::distance(first,last);
30 #endif
31 }
32 
33 template <class ForwardIterator>
34 size_t coinDistance(ForwardIterator first, ForwardIterator last)
35 {
36  size_t retVal;
37 #if defined(__SUNPRO_CC)
38  retVal = 0;
39  std::distance(first,last,retVal);
40 #else
41  retVal = std::distance(first,last);
42 #endif
43  return retVal;
44 }
45 
46 #endif