General Utility Library for C++17 25.4.1
Classes | Typedefs | Enumerations | Functions | Variables
gul17 Namespace Reference

Detailed Description

Namespace gul17 contains all functions and classes of the General Utility Library.

Classes

class  bad_expected_access
 The exception thrown by gul17::expected if value() is called, but no value is present. More...
 
class  ConvertingStringView
 A string view that can automatically convert numbers into strings. More...
 
class  expected
 An expected<T, E> is an object that normally contains an "expected" object of type T, but it can alternatively contain another, "unexpected" or "error" object of type E. More...
 
class  FailToInstantiate
 A helper class to debug types. More...
 
class  FinalAction
 FinalAction allows us to execute something if the FinalAction object leaves the scope. More...
 
class  HexdumpParameterForward
 Helper object used to enable a convenient syntax to dump things to a stream. More...
 
struct  IsContainerLike
 Helper type trait object to determine if a type is a container. More...
 
struct  MinMax
 Object that is designed to holds two values: minimum and maximum of something. More...
 
struct  OverloadSet
 A function object that works like an overload set of functions. More...
 
class  SlidingBuffer
 A circular data buffer of (semi-)fixed capacity to which elements can be added at the front or at the back. More...
 
class  SlidingBufferExposed
 A variant of SlidingBuffer that exposes the underlying container through its iterator interface. More...
 
class  SmallVector
 A resizable container with contiguous storage that can hold a specified number of elements without allocating memory on the heap. More...
 
class  span
 A view to a contiguous sequence of objects. More...
 
class  StandardDeviationMean
 A struct holding a standard deviation and a mean value. More...
 
class  ThreadPool
 A pool of worker threads with a task queue. More...
 
class  Trigger
 A class that allows sending triggers and waiting for them across different threads. More...
 
class  unexpected
 Class template for constructing the unexpected value of an expected object. More...
 

Typedefs

template<typename T >
using BitFunctionReturnType = std::enable_if_t< std::is_integral< T >::value and not std::is_same< std::decay_t< T >, bool >::value, std::decay_t< T > >
 Return type of the bit manipulation functions.
 
using statistics_result_type = double
 Type used to return statistic properties.
 
template<typename T >
using remove_cvref = typename std::remove_cv< std::remove_reference_t< T > >
 A template metafunction that removes const, volatile, and reference qualifiers from a type.
 
template<typename T >
using remove_cvref_t = typename remove_cvref< T >::type
 A template metafunction that removes const, volatile, and reference qualifiers from a type.
 

Enumerations

enum class  endian { endian::little , endian::big , endian::native }
 An enum to determine the endianness of multi-byte scalars on the current platform. More...
 
enum class  ShrinkBehavior { keep_front_elements , keep_back_elements }
 Determine how a SlidingBuffer handles decreases of its size. More...
 
enum class  TaskState { TaskState::pending , TaskState::running , TaskState::complete , TaskState::canceled }
 An enum describing the state of an individual task. More...
 

Functions

template<typename T = unsigned, typename ReturnT = BitFunctionReturnType<T>>
auto constexpr bit_set (unsigned bit) noexcept -> ReturnT
 Set a bit in an integral type.
 
template<typename T , typename ReturnT = BitFunctionReturnType<T>>
auto constexpr bit_set (T previous, unsigned bit) noexcept -> ReturnT
 Set a bit in an integral value.
 
template<typename T , typename ReturnT = BitFunctionReturnType<T>>
auto constexpr bit_reset (T previous, unsigned bit) noexcept -> ReturnT
 Reset a bit in an integral value.
 
template<typename T , typename ReturnT = BitFunctionReturnType<T>>
auto constexpr bit_flip (T previous, unsigned bit) noexcept -> ReturnT
 Flip a bit in an integral value.
 
template<typename T >
bool constexpr bit_test (T bits, unsigned bit) noexcept
 Test a bit in an integral value.
 
constexpr bool is_big_endian ()
 Determine whether this platform uses big-endian (Motorola) order for storing multi-byte quantities in memory.
 
constexpr bool is_little_endian ()
 Determine whether this platform uses little-endian (Intel) order for storing multi-byte quantities in memory.
 
constexpr char lowercase_ascii (char c) noexcept
 Return the ASCII lowercase equivalent of the given character (or the unchanged character, if it is not an ASCII letter).
 
GUL_EXPORT std::string lowercase_ascii (std::string_view str)
 Return a copy of the given string in which all ASCII characters are replaced by their lowercase equivalents.
 
GUL_EXPORT std::string & lowercase_ascii_inplace (std::string &str) noexcept
 Replace all ASCII characters in a string by their lowercase equivalents.
 
constexpr char uppercase_ascii (char c) noexcept
 Return the ASCII uppercase equivalent of the given character (or the unchanged character, if it is not an ASCII letter).
 
GUL_EXPORT std::string uppercase_ascii (std::string_view str)
 Return a copy of the given string in which all ASCII characters are replaced by their uppercase equivalents.
 
GUL_EXPORT std::string & uppercase_ascii_inplace (std::string &str) noexcept
 Replace all ASCII characters in a string by their uppercase equivalents.
 
std::string cat ()
 Efficiently concatenate an arbitrary number of strings and numbers.
 
std::string cat (const ConvertingStringView &s)
 
GUL_EXPORT std::string cat (const ConvertingStringView &s1, const ConvertingStringView &s2)
 
GUL_EXPORT std::string cat (const ConvertingStringView &s1, const ConvertingStringView &s2, const ConvertingStringView &s3)
 
GUL_EXPORT std::string cat (std::initializer_list< ConvertingStringView > pieces)
 
template<typename... Args, typename = std::enable_if_t<(sizeof...(Args) > 3)>>
std::string cat (const Args &... args)
 
GUL_EXPORT std::string escape (std::string_view in)
 Create a new string that looks like an ASCII-only C string literal of the input string.
 
GUL_EXPORT std::string unescape (std::string_view in)
 Evaluate a string with escaped characters to get the original string back.
 
template<typename F >
FinalAction< typename std::decay_t< F > > finally (F &&f) noexcept
 finally() - convenience function to generate a FinalAction
 
template<typename IntTypeA , typename IntTypeB >
constexpr auto gcd (IntTypeA a, IntTypeB b)
 Calculate the greatest common divisor of two integers using the Euclidean algorithm.
 
template<typename IntTypeA , typename IntTypeB >
constexpr auto lcm (IntTypeA a, IntTypeB b)
 Calculate the least common multiple of two integers.
 
template<typename IteratorT , typename = std::enable_if_t<detail::IsHexDumpIterator<IteratorT>::value>>
std::string hexdump (IteratorT begin, IteratorT end, std::string_view prompt="")
 Generate a hexdump of a data range and return it as a string.
 
template<typename ContainerT , typename = std::enable_if_t<detail::IsHexDumpContainer<ContainerT>::value>>
std::string hexdump (const ContainerT &cont, std::string_view prompt="")
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename IteratorT , typename = std::enable_if_t<detail::IsHexDumpIterator<IteratorT>::value>>
HexdumpParameterForward< const IteratorThexdump_stream (const IteratorT &begin, const IteratorT &end, std::string prompt="")
 Generate a hexdump of a data range that can be efficiently written to a stream using operator<<.
 
template<typename ContainerT , typename = std::enable_if_t<detail::IsHexDumpContainer<ContainerT>::value>>
HexdumpParameterForward< const decltype(std::declval< ContainerT >().cbegin())> hexdump_stream (const ContainerT &cont, std::string prompt="")
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename ContainerT , typename = std::enable_if_t<detail::IsHexDumpContainer<ContainerT>::value, decltype(HexdumpParameterForward<decltype(std::declval<ContainerT>().cbegin()), ContainerT> {}, 0)>>
HexdumpParameterForward< decltype(std::declval< ContainerT >().cbegin()), ContainerThexdump_stream (ContainerT &&cont, std::string prompt="")
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename StringContainer = std::vector<std::string>, typename ContainerInsertFct = void (*)(StringContainer&, std::string_view)>
StringContainer split (std::string_view text, std::string_view delimiter, ContainerInsertFct insert_fct=detail::emplace_back< StringContainer >)
 Separate a string at all occurrences of a delimiter, returning the strings between the delimiters in a container.
 
template<typename StringContainer = std::vector<std::string>, typename ContainerInsertFct = void (*)(StringContainer&, std::string_view)>
StringContainer split (std::string_view text, const std::regex &delimiter, ContainerInsertFct insert_fct=detail::emplace_back< StringContainer >)
 Separate a string at all occurrences of a delimiter described by a regular expression, returning the strings between the delimiters in a container.
 
template<typename StringContainer = std::vector<std::string_view>, typename ContainerInsertFct = void (*)(StringContainer&, std::string_view)>
StringContainer split_sv (std::string_view text, std::string_view delimiter, ContainerInsertFct insert_fct=detail::emplace_back< StringContainer >)
 Separate a string at all occurrences of a delimiter, returning the strings between the delimiters in a vector.
 
template<typename Iterator >
std::string join (Iterator begin, Iterator end, std::string_view glue)
 Concatenate all strings (or string-like elements) in a range, placing a delimiter between them.
 
template<typename StringContainer >
std::string join (const StringContainer &parts, std::string_view glue)
 Concatenate all strings (or string-like elements) in a range, placing a delimiter between them.
 
template<typename Iterator , typename ConversionFct >
std::string join (Iterator begin, Iterator end, std::string_view glue, ConversionFct to_string, std::size_t prealloc=0)
 Concatenate the strings resulting from calling the given function on each element in a range, placing a delimiter between them.
 
template<typename Container , typename ConversionFct >
std::string join (const Container &container, std::string_view glue, ConversionFct to_string, std::size_t prealloc=0)
 Concatenate the strings resulting from calling the given function on each element in a range, placing a delimiter between them.
 
template<typename ValueT >
constexpr auto abs (ValueT n) noexcept -> std::enable_if_t< std::is_unsigned< ValueT >::value, ValueT >
 Compute the absolute value of a number.
 
template<typename NumT , typename OrderT , typename = std::enable_if_t< std::is_arithmetic<NumT>::value and std::is_arithmetic<OrderT>::value >>
bool within_orders (const NumT a, const NumT b, const OrderT orders) noexcept(false)
 Determine if two numbers are almost equal, comparing only some significant digits.
 
template<typename NumT >
bool within_abs (NumT a, NumT b, NumT tol) noexcept
 Determine if two numbers are almost equal, allowing for an absolute difference.
 
template<typename NumT , typename = std::enable_if_t<std::is_floating_point<NumT>::value>>
bool within_ulp (NumT a, NumT b, unsigned int ulp)
 Determine if two numbers are almost equal, allowing for a difference of a given number of units-in-the-last-place (ULPs).
 
template<class NumT >
constexpr const NumTclamp (const NumT &v, const NumT &lo, const NumT &hi)
 Coerce a value to be within a given range.
 
template<class NumT , class Compare >
constexpr const NumTclamp (const NumT &v, const NumT &lo, const NumT &hi, Compare comp)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename... Fcts>
 OverloadSet (Fcts...) -> OverloadSet< Fcts... >
 
GUL_EXPORT std::string replace (std::string_view haystack, std::string_view needle, std::string_view hammer)
 Replace all occurrences of a string within another string, returning the result as a std::string.
 
GUL_EXPORT std::string & replace_inplace (std::string &haystack, std::string_view needle, std::string_view hammer)
 Replace all occurrences of a string within another string in-place.
 
template<typename ElementT , size_t in_capacity>
void swap (SmallVector< ElementT, in_capacity > &a, SmallVector< ElementT, in_capacity > &b)
 Exchange the contents of one SmallVector with those of another one.
 
template<typename ElementType , std::size_t Extent>
span< const unsigned char,((Extent==dynamic_extent) ? dynamic_extent :sizeof(ElementType) *Extent)> as_bytes (span< ElementType, Extent > s) noexcept
 Return a constant view to the byte representation of the elements of a given span.
 
template<class ElementType , size_t Extent, typename std::enable_if<!std::is_const< ElementType >::value, int >::type = 0>
span< unsigned char,((Extent==dynamic_extent) ? dynamic_extent :sizeof(ElementType) *Extent)> as_writable_bytes (span< ElementType, Extent > s) noexcept
 Return a writable view to the byte representation of the elements of a given span.
 
template<std::size_t N, typename E , std::size_t S>
constexpr auto get (span< E, S > s) -> decltype(s[N])
 Return a reference to the Nth element of a given span.
 
template<typename ElementT >
auto ElementAccessor ()
 Return a mock element accessor for containers.
 
template<typename ResultT = statistics_result_type, typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = typename std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>>
auto mean (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT
 Calculate the arithmetic mean value of all elements in a container.
 
template<typename ResultT = statistics_result_type, typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = typename std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>>
auto rms (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT
 Calculate the root mean square of all elements in a container.
 
template<typename ResultT = statistics_result_type, typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = typename std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>>
auto median (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT
 Find the median of all elements in a container.
 
template<typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = typename std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>>
auto maximum (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> DataT
 Return the maximum element value in a container.
 
template<typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = typename std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>>
auto minimum (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> DataT
 Return the minimum element value in a container.
 
template<typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = typename std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>>
auto min_max (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> MinMax< DataT >
 Find the minimum and maximum element values in a container.
 
template<typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = typename std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>>
auto remove_outliers (ContainerT &&cont, std::size_t outliers, Accessor accessor=ElementAccessor< ElementT >()) -> ContainerT &
 Remove elements that are far away from other elements.
 
template<typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = typename std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>>
auto remove_outliers (ContainerT const &cont, std::size_t outliers, Accessor accessor=ElementAccessor< ElementT >()) -> std::vector< ElementT >
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The original container is not modified.
 
template<typename ResultT = statistics_result_type, typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = typename std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename = std::enable_if_t<IsContainerLike<ContainerT>::value>>
auto standard_deviation (ContainerT const &container, Accessor accessor=ElementAccessor< ElementT >()) -> StandardDeviationMean< ResultT >
 Calculate the standard deviation of all elements in a container.
 
template<typename ResultT = statistics_result_type, typename ContainerT , typename ElementT = typename ContainerT::value_type, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = typename std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename OpClosure , typename = std::enable_if_t<IsContainerLike<ContainerT>::value>>
auto accumulate (ContainerT const &container, OpClosure op, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT
 Calculate some aggregate value from all elements of a container.
 
template<typename ResultT = statistics_result_type, typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = std::decay_t<std::result_of_t<Accessor(ElementT)>>>
auto mean (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename ResultT = statistics_result_type, typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = std::decay_t<std::result_of_t<Accessor(ElementT)>>>
auto rms (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename ResultT = statistics_result_type, typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = std::decay_t<std::result_of_t<Accessor(ElementT)>>>
auto median (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = std::decay_t<std::result_of_t<Accessor(ElementT)>>>
auto maximum (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> DataT
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = std::decay_t<std::result_of_t<Accessor(ElementT)>>>
auto minimum (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> DataT
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = std::decay_t<std::result_of_t<Accessor(ElementT)>>>
auto min_max (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> MinMax< DataT >
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = std::decay_t<std::result_of_t<Accessor(ElementT)>>>
auto remove_outliers (IteratorT const &begin, IteratorT const &end, std::size_t outliers, Accessor accessor=ElementAccessor< ElementT >()) -> std::vector< ElementT >
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The original container is not modified.
 
template<typename ResultT = statistics_result_type, typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = std::decay_t<std::result_of_t<Accessor(ElementT)>>>
auto standard_deviation (IteratorT const &begin, IteratorT const &end, Accessor accessor=ElementAccessor< ElementT >()) -> StandardDeviationMean< ResultT >
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename ResultT = statistics_result_type, typename IteratorT , typename ElementT = std::decay_t<decltype(*std::declval<IteratorT>())>, typename Accessor = std::result_of_t<decltype(ElementAccessor<ElementT>())(ElementT)>(*)(ElementT const&), typename DataT = std::decay_t<std::result_of_t<Accessor(ElementT)>>, typename OpClosure >
auto accumulate (IteratorT const &begin, IteratorT const &end, OpClosure op, Accessor accessor=ElementAccessor< ElementT >()) -> ResultT
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename Integer , std::enable_if_t< std::is_integral< Integer >::value, bool > = true>
std::string hex_string (Integer v)
 Return the hexadecimal ASCII representation of an integer value.
 
template<typename Iterator >
std::string hex_string (Iterator begin, Iterator end, std::string_view separator="")
 Return the hexadecimal ASCII representation of a range of integer values.
 
template<typename Integer , size_t num_elements, std::enable_if_t< std::is_integral< Integer >::value, bool > = true>
std::string hex_string (const Integer(&array)[num_elements], std::string_view separator="")
 Return the hexadecimal ASCII representation of an array with integer values.
 
template<typename Container , std::enable_if_t< IsContainerLike< Container >::value, bool > = true>
std::string hex_string (const Container &container, std::string_view separator="")
 Return the hexadecimal ASCII representation of a container with integer values.
 
GUL_EXPORT std::string null_safe_string (const char *char_ptr)
 Safely construct a std::string from a C string or a null pointer.
 
GUL_EXPORT std::string_view null_safe_string_view (const char *char_ptr)
 Safely construct a string_view from a char pointer.
 
GUL_EXPORT std::string repeat (std::string_view str, std::size_t n)
 Repeat a string N times.
 
GUL_EXPORT std::string safe_string (const char *char_ptr, std::size_t length)
 Safely construct a std::string from a char pointer and a length.
 
GUL_EXPORT std::string_view safe_string_view (const char *char_ptr, std::size_t length)
 Safely construct a string_view from a char pointer and a length.
 
constexpr bool contains (std::string_view haystack, std::string_view needle) noexcept
 Determine whether a string contains another string.
 
constexpr bool contains (std::string_view haystack, char needle) noexcept
 Determine whether a string contains a certain character.
 
constexpr bool ends_with (std::string_view str, std::string_view suffix) noexcept
 Determine whether a string ends with another string.
 
constexpr bool ends_with (std::string_view str, char c) noexcept
 Determine whether a string ends with a certain character.
 
constexpr bool starts_with (std::string_view str, std::string_view prefix) noexcept
 Determine whether a string starts with another string.
 
constexpr bool starts_with (std::string_view str, char c) noexcept
 Determine whether a string starts with a certain character.
 
constexpr bool equals_nocase (std::string_view str1, std::string_view str2) noexcept
 Determine whether a string is equal to another one, making no distinction between upper and lower case ASCII characters.
 
constexpr bool contains_nocase (std::string_view haystack, std::string_view needle) noexcept
 Determine whether a string contains another string.
 
constexpr bool contains_nocase (std::string_view haystack, char needle) noexcept
 Determine whether a string contains a certain character.
 
constexpr bool ends_with_nocase (std::string_view str, std::string_view suffix) noexcept
 Determine whether a string ends with another string.
 
constexpr bool ends_with_nocase (std::string_view str, char c) noexcept
 Determine whether a string ends with a certain character.
 
constexpr bool starts_with_nocase (std::string_view str, std::string_view prefix) noexcept
 Determine whether a string starts with another string.
 
constexpr bool starts_with_nocase (std::string_view str, char c) noexcept
 Determine whether a string starts with a certain character.
 
std::shared_ptr< ThreadPoolmake_thread_pool (std::size_t num_threads, std::size_t capacity=ThreadPool::default_capacity)
 Create a thread pool with the desired number of threads and the specified capacity for queuing tasks.
 
std::chrono::steady_clock::time_point tic ()
 Return the current time as a std::chrono time_point.
 
template<class TimeUnitType = std::chrono::duration<double>>
auto toc (std::chrono::steady_clock::time_point t0)
 Return the elapsed time in seconds (or a different unit) since the given time point.
 
template<class Rep , class Period >
bool sleep (const std::chrono::duration< Rep, Period > &duration, const Trigger &trg)
 Sleep for at least the given time span, with the option of being woken up from another thread.
 
bool sleep (double seconds, const Trigger &trg)
 Sleep for a given number of seconds, with the option of being woken up from another thread.
 
template<class Rep , class Period >
bool sleep (const std::chrono::duration< Rep, Period > &duration)
 Sleep for a given time span.
 
bool sleep (double seconds)
 Sleep for a given number of seconds.
 
template<typename NumberType >
constexpr std::enable_if_t< std::is_integral< NumberType >::value and std::is_unsigned< NumberType >::value, std::optional< NumberType > > to_number (std::string_view str) noexcept
 Convert an ASCII std::string_view into a number.
 
template<typename NumberType >
constexpr std::enable_if_t< std::is_integral< NumberType >::value and std::is_signed< NumberType >::value, std::optional< NumberType > > to_number (std::string_view str) noexcept
 
template<typename NumberType >
constexpr std::enable_if_t< std::is_floating_point< NumberType >::value, std::optional< NumberType > > to_number (std::string_view str) noexcept
 
template<>
constexpr std::optional< boolto_number< bool > (std::string_view str) noexcept
 
template<typename StringContainer = std::vector<std::string>, typename ContainerInsertFct = void (*)(StringContainer&, std::string_view)>
StringContainer tokenize (std::string_view str, std::string_view delimiters=default_whitespace_characters, ContainerInsertFct insert_fct=detail::emplace_back< StringContainer >)
 Split the given string into a vector of substrings (tokens) delimited by any of the characters in the delimiters string.
 
template<typename StringContainer = std::vector<std::string_view>, typename ContainerInsertFct = void (*)(StringContainer&, std::string_view)>
StringContainer tokenize_sv (std::string_view str, std::string_view delimiters=default_whitespace_characters, ContainerInsertFct insert_fct=detail::emplace_back< StringContainer >)
 Split the given string into a vector of substrings (tokens) delimited by any of the characters in the delimiters string.
 
GUL_EXPORT std::string trim (std::string_view str, std::string_view ws_chars=default_whitespace_characters)
 Trim leading and trailing whitespace (or a custom set of characters) from a string, returning a new std::string.
 
GUL_EXPORT std::string_view trim_sv (std::string_view str, std::string_view ws_chars=default_whitespace_characters)
 Trim leading and trailing whitespace (or a custom set of characters) from a string, returning a view into the original string.
 
GUL_EXPORT std::string trim_left (std::string_view str, std::string_view ws_chars=default_whitespace_characters)
 Trim leading whitespace (or a custom set of characters) from a string, returning a new std::string.
 
GUL_EXPORT std::string_view trim_left_sv (std::string_view str, std::string_view ws_chars=default_whitespace_characters)
 Trim leading whitespace (or a custom set of characters) from a string, returning a view into the original string.
 
GUL_EXPORT std::string trim_right (std::string_view str, std::string_view ws_chars=default_whitespace_characters)
 Trim trailing whitespace (or a custom set of characters) from a string, returning a new std::string.
 
GUL_EXPORT std::string_view trim_right_sv (std::string_view str, std::string_view ws_chars=default_whitespace_characters)
 Trim trailing whitespace (or a custom set of characters) from a string, returning a view into the original string.
 
template<class T >
constexpr std::string_view type_name ()
 Generate a human readable string describing a type.
 

Variables

GUL_EXPORT const std::string_view default_whitespace_characters { " \t\r\n\a\b\f\v" }
 The default characters that are treated as whitespace by GUL.
 
GUL_EXPORT const std::array< char, 16 > hex_digits
 The 16 digits for hexadecimal numbers ("0123456789abcdef").
 
GUL_EXPORT char constversion
 Holds the version of the library.