CoinDistance.hpp 1.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
/* $Id$ */
// Copyright (C) 2000, International Business Machines
// Corporation and others.  All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).

#ifndef CoinDistance_H
#define CoinDistance_H

#include <iterator>

//-------------------------------------------------------------------
//
// Attempt to provide an std::distance function
// that will work on multiple platforms
//
//-------------------------------------------------------------------

/** CoinDistance

This is the Coin implementation of the std::function that is 
designed to work on multiple platforms.
*/
template < class ForwardIterator, class Distance >
void coinDistance(ForwardIterator first, ForwardIterator last,
  Distance &n)
{
#if defined(__SUNPRO_CC)
  n = 0;
  std::distance(first, last, n);
#else
  n = std::distance(first, last);
#endif
}

template < class ForwardIterator >
size_t coinDistance(ForwardIterator first, ForwardIterator last)
{
  size_t retVal;
#if defined(__SUNPRO_CC)
  retVal = 0;
  std::distance(first, last, retVal);
#else
  retVal = std::distance(first, last);
#endif
  return retVal;
}

#endif

/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
*/