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

- File List
- File Members

# /home/coin/svn-release/Alps-1.4.8/CoinUtils/src/CoinDistance.hpp

Go to the documentation of this file.

    00001 /* $Id: CoinDistance.hpp 1372 2011-01-03 23:31:00Z lou $ */
    00002 // Copyright (C) 2000, International Business Machines
    00003 // Corporation and others.  All Rights Reserved.
    00004 // This code is licensed under the terms of the Eclipse Public License (EPL).
    00005
    00006 #ifndef CoinDistance_H
    00007 #define CoinDistance_H
    00008
    00009 #include <iterator>
    00010
    00011 //-------------------------------------------------------------------
    00012 //
    00013 // Attempt to provide an std::distance function
    00014 // that will work on multiple platforms
    00015 //
    00016 //-------------------------------------------------------------------
    00017
    00023 template <class ForwardIterator, class Distance>
    00024 void coinDistance(ForwardIterator first, ForwardIterator last,
    00025                   Distance& n)
    00026 {
    00027 #if defined(__SUNPRO_CC)
    00028    n = 0;
    00029    std::distance(first,last,n);
    00030 #else
    00031    n = std::distance(first,last);
    00032 #endif
    00033 }
    00034
    00035 template <class ForwardIterator>
    00036 size_t coinDistance(ForwardIterator first, ForwardIterator last)
    00037 {
    00038    size_t retVal;
    00039 #if defined(__SUNPRO_CC)
    00040    retVal = 0;
    00041    std::distance(first,last,retVal);
    00042 #else
    00043    retVal = std::distance(first,last);
    00044 #endif
    00045   return retVal;
    00046 }
    00047
    00048 #endif