#ifndef MSL_CPP_ALGORITHM_H #define MSL_CPP_ALGORITHM_H #include namespace std { template inline const T& max(const T& a, const T& b) { return (a < b) ? b : a; } template inline const T& min(const T& a, const T& b) { return (b < a) ? b : a; } template inline TPtr find(TPtr first, TPtr last, const T& value) { while (first != last && *first != value) { ++first; } return first; } template inline long distance(TPtr first, TPtr last) { random_access_iterator_tag tag; return __distance(first, last, tag); } template inline long __distance(TPtr first, TPtr last, random_access_iterator_tag tag) { long dist = (long)last - (long)first; return dist / (long)sizeof(TPtr); } } #endif