30 template<
typename T1,
typename T2>
31 inline constexpr
bool decayed_is_same = std::is_same_v<std::decay_t<T1>, std::decay_t<T2>>;
40 template<
typename Enum>
43 return static_cast<std::underlying_type_t<Enum>
>(
e);
52 template<
typename Container,
typename Value>
55 static bool eval(
const Container& container,
const Value& value)
57 typename Container::const_iterator end = container.end();
58 return std::find(container.begin(), end, value) != end;
67 template<
typename Container>
70 static bool eval(
const Container& container,
const typename Container::key_type& value)
72 return container.find(value) != container.end();
86 template<
typename Container,
typename Value>
87 inline bool contains(
const Container& container,
const Value& value)
106 template<
typename Container,
typename Predicate>
107 void erase_if(Container& container,
const Predicate& predicate)
109 container.erase(std::remove_if(container.begin(), container.end(), predicate), container.end());
117 template<
typename Container,
typename Value>
118 std::size_t
erase(Container& container,
const Value& value)
120 auto iter =
std::remove(container.begin(), container.end(), value);
121 auto num_removed = container.end() - iter;
122 container.erase(iter, container.end());
131 template<
typename Container,
typename Predicate>
132 void sort_if(Container& container,
const Predicate& predicate)
134 std::sort(container.begin(), container.end(), predicate);
140 template<
typename Container,
typename Value>
141 auto*
find(Container& container,
const Value& value)
143 auto res = container.find(value);
144 return (res == container.end()) ? nullptr : &*res;
152 template<
typename T,
typename Range>
155 return std::vector<T>(range.begin(), range.end());
172 return std::forward<T>(
t);
178 template<
typename Container,
typename Value,
typename Projection = implementation::
identity>
179 auto find(Container& container,
const Value& value,
const Projection& projection = {})
181 auto end = container.end();
182 for(
auto iter = container.begin(); iter != end; ++iter) {
183 if(std::invoke(projection, *iter) == value) {
T end(const std::pair< T, T > &p)
void remove()
Removes a tip.
Contains the implementation details for lexical_cast and shouldn't be used directly.
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.
std::size_t erase(Container &container, const Value &value)
Convenience wrapper for using std::remove on a container.
std::vector< T > from_range(Range &&range)
Returns a vector whose elements are initialized from the given range.
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(...).
void erase_if(Container &container, const Predicate &predicate)
Convenience wrapper for using std::remove_if on a container.
constexpr bool dependent_false_v
Workaround for the fact that static_assert(false) is invalid.
void sort_if(Container &container, const Predicate &predicate)
Convenience wrapper for using std::sort on a container.
constexpr std::underlying_type_t< Enum > to_underlying(Enum e) noexcept
auto * find(Container &container, const Value &value)
Convenience wrapper for using find on a container without needing to comare to end()
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