18#ifndef TRINITY_ADVSTD_H
19#define TRINITY_ADVSTD_H
23#ifdef __cpp_lib_bit_cast
34[[nodiscard]]
constexpr bool is_eq(std::partial_ordering cmp)
noexcept {
return cmp == 0; }
35[[nodiscard]]
constexpr bool is_neq(std::partial_ordering cmp)
noexcept {
return cmp != 0; }
37#ifdef __cpp_lib_bit_cast
41template <
typename To,
typename From,
42 std::enable_if_t<std::conjunction_v<
43 std::bool_constant<
sizeof(To) ==
sizeof(From)>,
44 std::is_trivially_copyable<To>,
45 std::is_trivially_copyable<From>>,
int> = 0>
46[[nodiscard]]
constexpr To
bit_cast(From
const& from)
noexcept
49 std::memcpy(&to, &from,
sizeof(To));
57#ifndef __cpp_lib_ranges_contains
64#ifndef __cpp_lib_ranges_contains
67 template<std::input_iterator I, std::sentinel_for<I> S,
class T,
class Proj = std::
identity>
68 requires std::indirect_binary_predicate<std::ranges::equal_to, std::projected<I, Proj>, T
const*>
69 [[nodiscard]]
inline constexpr bool operator()(I first, S last, T
const& value, Proj proj = {})
const
71 return std::ranges::find(std::move(first), last, value, proj) != last;
74 template<std::ranges::input_range R,
class T,
class Proj = std::
identity>
75 requires std::indirect_binary_predicate<std::ranges::equal_to, std::projected<std::ranges::iterator_t<R>, Proj>, T
const*>
76 [[nodiscard]]
inline constexpr bool operator()(R&& r, T
const& value, Proj proj = {})
const
78 auto first = std::ranges::begin(r);
79 auto last = std::ranges::end(r);
80 return std::ranges::find(std::move(first), last, value, proj) != last;
struct advstd::ranges::Contains contains
constexpr bool is_eq(std::partial_ordering cmp) noexcept
constexpr bool is_neq(std::partial_ordering cmp) noexcept
constexpr To bit_cast(From const &from) noexcept
constexpr bool operator()(R &&r, T const &value, Proj proj={}) const
constexpr bool operator()(I first, S last, T const &value, Proj proj={}) const