31template<
typename T1,
typename T2>
32inline constexpr bool decayed_is_same = std::is_same_v<std::decay_t<T1>, std::decay_t<T2>>;
41template<
typename Enum>
44 return static_cast<std::underlying_type_t<Enum>
>(
e);
53template<
typename Container,
typename Value>
56 static bool eval(
const Container& container,
const Value&
value)
58 typename Container::const_iterator end = container.end();
59 return std::find(container.begin(), end,
value) != end;
68template<
typename Container>
71 static bool eval(
const Container& container,
const typename Container::key_type&
value)
73 return container.find(
value) != container.end();
87template<
typename Container,
typename Value>
107template<
typename Container,
typename Predicate>
108void erase_if(Container& container,
const Predicate& predicate)
110 container.erase(std::remove_if(container.begin(), container.end(), predicate), container.end());
118template<
typename Container,
typename Value>
121 auto iter = std::remove(container.begin(), container.end(),
value);
122 auto num_removed = container.end() - iter;
123 container.erase(iter, container.end());
132template<
typename Container,
typename Predicate>
133void sort_if(Container& container,
const Predicate& predicate)
135 std::sort(container.begin(), container.end(), predicate);
141template<
typename Container,
typename Value>
144 auto res = container.find(
value);
145 return (res == container.end()) ? nullptr : &*res;
151template<
typename Container,
typename Predicate>
152auto*
find_if(Container& container,
const Predicate& predicate)
154 auto res = std::find_if(container.begin(), container.end(), predicate);
155 return (res == container.end()) ? nullptr : &*res;
163template<
typename T,
typename Range>
166 return std::vector<T>(range.begin(), range.end());
175inline std::tm*
localtime_r(
const std::time_t* time, std::tm* result)
178 return ::localtime_s(result, time) == 0 ? result :
nullptr;
180 return ::localtime_r(time, result);
188template<
class... Ts>
struct overload : Ts... {
using Ts::operator()...; };
206 return std::forward<T>(
t);
212template<
typename Container,
typename Value,
typename Projection = implementation::
identity>
213auto find(Container& container,
const Value&
value,
const Projection& projection = {})
215 auto end = container.end();
216 for(
auto iter = container.begin(); iter != end; ++iter) {
217 if(std::invoke(projection, *iter) ==
value) {
Contains the implementation details for lexical_cast and shouldn't be used directly.
T end(const std::pair< T, T > &p)
auto find(Container &container, const Value &value, const Projection &projection={})
constexpr bool decayed_is_same
Equivalent to as std::is_same_v except both types are passed through std::decay first.
auto * find_if(Container &container, const Predicate &predicate)
Convenience wrapper for using find_if on a container without needing to comare to end()
std::size_t erase(Container &container, const Value &value)
Convenience wrapper for using std::remove on a container.
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
std::string get_unknown_exception_type()
Utility function for finding the type of thing caught with catch(...).
constexpr std::underlying_type_t< Enum > to_underlying(Enum e) noexcept
void erase_if(Container &container, const Predicate &predicate)
Convenience wrapper for using std::remove_if on a container.
std::vector< T > from_range(Range &&range)
Returns a vector whose elements are initialized from the given range.
constexpr bool dependent_false_v
Workaround for the fact that static_assert(false) is invalid.
auto * find(Container &container, const Value &value)
Convenience wrapper for using find on a container without needing to comare to end()
void sort_if(Container &container, const Predicate &predicate)
Convenience wrapper for using std::sort on a container.
std::tm * localtime_r(const std::time_t *time, std::tm *result)
std::unique_ptr< MIX_Audio, decltype(&MIX_DestroyAudio)> value
static bool eval(const Container &container, const typename Container::key_type &value)
A struct that exists to implement a generic wrapper for std::find.
static bool eval(const Container &container, const Value &value)
constexpr T && operator()(T &&t) const noexcept