functionvalue 100% (#2389)

* functionvalue 100%

* Fix ninja always thinking the build is dirty due to nonexistent dependent file
This commit is contained in:
LagoLunatic
2025-04-12 02:12:27 -04:00
committed by GitHub
parent cc3e0856bf
commit b52d288cd0
11 changed files with 308 additions and 200 deletions
@@ -3,10 +3,36 @@
#include <iterator.h>
#include <string.h>
#include <functional.h>
namespace std {
template <class ForwardIterator, class T, typename Predicate>
inline ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T& val, Predicate p) {
typedef typename iterator_traits<ForwardIterator>::difference_type difference_type;
difference_type len = std::distance(first, last);
while (len > 0) {
ForwardIterator i = first;
difference_type step = len / 2;
std::advance(i, step);
if (p(*i, val)) {
first = ++i;
len -= step + 1;
} else {
len = step;
}
}
return first;
}
template <class ForwardIterator, class T>
ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T& val) {
// For some reason, calling the other lower_bound matches for debug, but not for retail:
// return lower_bound(first, last, val, std::detail::less<T, T>());
typedef typename iterator_traits<ForwardIterator>::difference_type difference_type;
difference_type len = std::distance(first, last);
@@ -47,9 +73,6 @@ ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T
return first;
}
template <class ForwardIterator, class T>
ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T& val);
template<class InputIt, class UnaryPredicate>
InputIt find_if(InputIt first, InputIt last, UnaryPredicate p) {
while (first != last && !p(*first)) {
@@ -2,11 +2,21 @@
#define MSL_FUNCTIONAL_H_
namespace std {
template <class T> struct less {
bool operator()(const T& a, const T& b) const {
return a < b;
}
namespace detail {
template <class T1, class T2>
struct less {
bool operator()(const T1& lhs, const T2& rhs) const { return lhs < rhs; }
};
} // namespace detail
template <class T>
struct less : public std::detail::less<T, T> {
bool operator()(const T& lhs, const T& rhs) const { return lhs < rhs; }
};
} // namespace std
#endif
@@ -28,6 +28,20 @@ struct iterator_traits<T*> {
typedef random_access_iterator_tag iterator_category;
};
template<
class Category,
class T,
class Distance,
class Pointer,
class Reference
> struct iterator {
typedef Distance difference_type;
typedef T value_type;
typedef Pointer pointer;
typedef Reference reference;
typedef Category iterator_category;
};
template <class InputIterator, class Distance>
inline void __advance(InputIterator& i, Distance n, input_iterator_tag) {
for (; n > 0; --n)