mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
c4c812c154
We now have a C++ red-black tree implementation that implements standard template library compatible APIs while compiling 10x faster than libcxx. It's not as beautiful as the red-black tree implementation in Plinko but this will get the job done and the test proves it upholds all invariants This change also restores CheckForMemoryLeaks() support and fixes a real actual bug I discovered with Doug Lea's dlmalloc_inspect_all() function.
38 lines
874 B
C++
38 lines
874 B
C++
// -*-mode:c++;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8-*-
|
|
// vi: set et ft=cpp ts=4 sts=4 sw=4 fenc=utf-8 :vi
|
|
#ifndef CTL_LESS_H_
|
|
#define CTL_LESS_H_
|
|
#include "utility.h"
|
|
|
|
namespace ctl {
|
|
|
|
template<class T = void>
|
|
struct less
|
|
{
|
|
constexpr bool operator()(const T& lhs, const T& rhs) const
|
|
{
|
|
return lhs < rhs;
|
|
}
|
|
|
|
typedef T first_argument_type;
|
|
typedef T second_argument_type;
|
|
typedef bool result_type;
|
|
};
|
|
|
|
template<>
|
|
struct less<void>
|
|
{
|
|
template<class T, class U>
|
|
constexpr auto operator()(T&& lhs,
|
|
U&& rhs) const -> decltype(ctl::forward<T>(lhs) <
|
|
ctl::forward<U>(rhs))
|
|
{
|
|
return ctl::forward<T>(lhs) < ctl::forward<U>(rhs);
|
|
}
|
|
|
|
typedef void is_transparent;
|
|
};
|
|
|
|
} // namespace ctl
|
|
|
|
#endif /* CTL_LESS_H_ */
|