- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Osi-0.98.1/CoinUtils/src/CoinDistance.hpp

Go to the documentation of this file.

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