![]() |
MySQL 8.4.4
Source Code Documentation
|
#include <assert.h>
#include <ctype.h>
#include <stddef.h>
#include <algorithm>
#include <iterator>
#include <optional>
#include <type_traits>
Go to the source code of this file.
Classes | |
struct | ReturnValueOrError< VALUE_TYPE > |
Utility to allow returning values from functions which can fail (until we have std::optional). More... | |
Namespaces | |
namespace | myu |
Functions | |
template<typename Container_type > | |
void | delete_container_pointers (Container_type &container) |
Clears a container, but deletes all objects that the elements point to first. More... | |
template<typename Container_type > | |
void | my_free_container_pointers (Container_type &container) |
Clears a container, but frees all objects that the elements point to first. More... | |
template<typename T > | |
constexpr T | pointer_cast (void *p) |
Casts from one pointer type, to another, without using reinterpret_cast or C-style cast: foo f; bar *b= pointer_cast<bar>(f); This avoids having to do: foo f; bar *b= static_cast<bar>(static_cast<void*>(f));. More... | |
template<typename T > | |
constexpr T | pointer_cast (const void *p) |
template<typename Target , typename Source > | |
Target | down_cast (Source *arg) |
Casts from one pointer type to another in a type hierarchy. More... | |
template<typename Target , typename Source > | |
Target | down_cast (Source &arg) |
Casts from one reference type to another in a type hierarchy. More... | |
template<typename To > | |
To | implicit_cast (To x) |
Sometimes the compiler insists that types be the same and does not do any implicit conversion. More... | |
template<class T , size_t N> | |
constexpr size_t | array_elements (T(&)[N]) noexcept |
Number of elements in a constant C array. More... | |
template<class InputIt , class Pred , class Action > | |
void | myu::Split (InputIt first, InputIt last, Pred &&pred, Action &&action) |
Split a range into sub ranges delimited by elements satisfying a predicate. More... | |
template<class InputIt , class Pred > | |
InputIt | myu::FindTrimmedEnd (InputIt first, InputIt last, Pred &&pred) |
Search backwards for the first occurrence of an element which does not satisfy the trimming predicate, and return an InputIt to the element after it. More... | |
template<class InputIt , class Pred > | |
std::pair< InputIt, InputIt > | myu::FindTrimmedRange (InputIt first, InputIt last, Pred &&pred) |
Searches for a sub range such that no elements before or after fail to satisfy the trimming predicate. More... | |
Variables | |
const auto | myu::IsSpace = [](char c) { return isspace(c); } |
Convenience lambdas for common predicates. More... | |
const auto | myu::IsComma = [](char c) { return c == ','; } |
|
constexprnoexcept |
Number of elements in a constant C array.
void delete_container_pointers | ( | Container_type & | container | ) |
Clears a container, but deletes all objects that the elements point to first.
Container_type | Container of pointers. |
Casts from one reference type to another in a type hierarchy.
In debug mode, we verify the cast is indeed legal.
Target | The descendent type, must be a reference type. |
Source | The parent type. |
arg | The reference to be down-cast. |
Casts from one pointer type to another in a type hierarchy.
In debug mode, we verify the cast is indeed legal.
Target | The descendent type, must be a pointer type. |
Source | The parent type. |
arg | The pointer to be down-cast. |
|
inline |
Sometimes the compiler insists that types be the same and does not do any implicit conversion.
For example: Derived1 *a; Derived2 *b; // Derived1 and 2 are children classes of Base Base *x= cond ? a : b; // Error, need to force a cast.
Use: Base x= cond ? implicit_cast<Base>(a) : implicit_cast<Base*>(b); static_cast would work too, but would be less safe (allows any pointer-to-pointer conversion, not only up-casts).
void my_free_container_pointers | ( | Container_type & | container | ) |
Clears a container, but frees all objects that the elements point to first.
Container_type | Container of pointers. |
|
constexpr |
|
constexpr |
Casts from one pointer type, to another, without using reinterpret_cast or C-style cast: foo f; bar *b= pointer_cast<bar>(f); This avoids having to do: foo f; bar *b= static_cast<bar>(static_cast<void*>(f));.