#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 = reinterpret_cast(last) - reinterpret_cast(first); return dist / static_cast(sizeof(TPtr)); } template inline T& move(T& x) { return x; } template inline void swap(T& a, T& b) { T tmp = move(a); a = move(b); b = move(tmp); } } // namespace std #endif