You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.2 KiB
C++
75 lines
2.2 KiB
C++
// -*- c++ -*-
|
|
#pragma once
|
|
|
|
#include <xmemory>
|
|
|
|
#pragma push_macro("_Ty")
|
|
#define _Ty(x) constexpr _Ty(x)
|
|
#pragma push_macro("_Ty")
|
|
#define _Ty(x) _Ty(x) _Pragma("pop_macro(\"_Ty\")")
|
|
|
|
|
|
#pragma push_macro("max_element")
|
|
#define max_element constexpr max_element _Pragma("pop_macro(\"max_element\")")
|
|
#pragma push_macro("max_element")
|
|
#define max_element constexpr max_element _Pragma("pop_macro(\"max_element\")")
|
|
|
|
#pragma push_macro("min_element")
|
|
#define min_element constexpr min_element _Pragma("pop_macro(\"min_element\")")
|
|
#pragma push_macro("min_element")
|
|
#define min_element constexpr min_element _Pragma("pop_macro(\"min_element\")")
|
|
|
|
|
|
#pragma push_macro("_Max_element")
|
|
#define _Max_element constexpr _Max_element _Pragma("pop_macro(\"_Max_element\")")
|
|
#pragma push_macro("_Min_element")
|
|
#define _Min_element constexpr _Min_element _Pragma("pop_macro(\"_Min_element\")")
|
|
|
|
// min/max
|
|
#pragma push_macro("_Post_equal_to_")
|
|
#define _Post_equal_to_(x) constexpr
|
|
|
|
#include_next <algorithm>
|
|
|
|
#pragma pop_macro("_Post_equal_to_")
|
|
#pragma pop_macro("_Ty")
|
|
|
|
namespace std
|
|
{
|
|
|
|
template <typename InputIt1, typename InputIt2>
|
|
inline bool equal(
|
|
InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2)
|
|
{
|
|
return equal(first1, last1, first2, last2, std::equal_to<>{});
|
|
}
|
|
|
|
template <typename InputIt1, typename InputIt2, typename BinaryPredicate>
|
|
inline bool equal(
|
|
InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2,
|
|
BinaryPredicate p)
|
|
{
|
|
if constexpr(std::is_same_v<
|
|
std::random_access_iterator_tag,
|
|
typename std::iterator_traits<InputIt1>::iterator_category> &&
|
|
std::is_same_v<
|
|
std::random_access_iterator_tag,
|
|
typename std::iterator_traits<InputIt2>::iterator_category>)
|
|
{
|
|
if (last1 - first1 != last2 - first2) return false;
|
|
for (; first1 != last1; ++first1, ++first2)
|
|
if (!p(*first1, *first2)) return false;
|
|
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
|
|
if (!p(*first1, *first2)) return false;
|
|
|
|
return first1 == last1 && first2 == last2;
|
|
}
|
|
}
|
|
|
|
}
|