• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/build/buildd/coinutils-2.6.4/CoinUtils/src/CoinDistance.hpp

Go to the documentation of this file.
00001 /* $Id: CoinDistance.hpp 1215 2009-11-05 11:03:04Z forrest $ */
00002 // Copyright (C) 2000, International Business Machines
00003 // Corporation and others.  All Rights Reserved.
00004 #ifndef CoinDistance_H
00005 #define CoinDistance_H
00006 
00007 #include <iterator>
00008 
00009 //-------------------------------------------------------------------
00010 //
00011 // Attempt to provide an std::distance function
00012 // that will work on multiple platforms
00013 //
00014 //-------------------------------------------------------------------
00015 
00021 template <class ForwardIterator, class Distance>
00022 void coinDistance(ForwardIterator first, ForwardIterator last,
00023                   Distance& n)
00024 {
00025 #if defined(__SUNPRO_CC)
00026    n = 0;
00027    std::distance(first,last,n);
00028 #else
00029    n = std::distance(first,last);
00030 #endif
00031 }
00032 
00033 template <class ForwardIterator>
00034 size_t coinDistance(ForwardIterator first, ForwardIterator last)
00035 {
00036    size_t retVal;
00037 #if defined(__SUNPRO_CC)
00038    retVal = 0;
00039    std::distance(first,last,retVal);
00040 #else
00041    retVal = std::distance(first,last);
00042 #endif
00043   return retVal;
00044 }
00045 
00046 #endif

Generated on Fri Oct 15 2010 18:21:02 by  doxygen 1.7.1