Files
ogws/include/MSL/algorithm
T
2023-06-25 16:52:48 -04:00

43 lines
944 B
Plaintext

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