Overview Examples Screenshots Comparisons Applications Download Documentation Tutorials Bazaar Status & Roadmap FAQ Authors & License Forums Funding Ultimate++
Search on this site

 Small utility functions

template <class Tconstexpr const T& min(const T& a, const T& b, ...)

Returns the least of all arguments.

template <class Tconstexpr const T& max(const T& a, const T& b, ...)

Returns the greatest of all arguments.

template <class Tconstexpr T clamp(const T& x, const T& min_, const T& max_)

Returns x if it is between min_ and max_ .

If x is lower than min_ it returns min_ .

If x is higher than max_ it returns max_ ..

template <class T, class T1, ...> int findarg(const T& x, const T1& p0, ...)

Searches the list of arguments for the value of x. If it is found, function returns the index of argument (starting with 0). If not found, -1 is returned.

template <class T, class T1, class V1, ..., class D>

constexpr D decode(const T& x, const T1& p0, const V1& v0, ..., const D& def)

Searches the list of argument pairs for the value of x to be equal to the first argument in the pair. If found, returns the second argument of pair. If no match is found, returns the last argument def.

template <class T, class T1, ...> T get_i(int i, const T& p0, const T1& p1, ...)

const char *get_i(int i, const char *p0, const char *p1, ...)

Returns parameter pi. If i is negative, returns p0, if it is greater then the last parameter, returns the last parameter.

template <class F, class T, class T1, ...> void foreach_arg(F fn, const T& p0, const T1& p1, ...)

Performs fn for each of arguments (argument is passed as fn parameter). Designed to be applied to a parameter pack.

template <class I, typename... Argsvoid iter_set(I t, Args&& ...args)

Writes arguments to a sequence pointed to by iterator t. Designed to be applied to a parameter pack.

template <class I, typename... Argsvoid iter_get(I s, Args& ...args)

Reads arguments from a sequence pointed to by iterator t. Designed to be applied to a parameter pack.

template <class C, typename... ArgsC gather(Args&& ...args)

Converts arguments into container. Designed to be applied to a parameter pack.

template <class C, typename... Argsint scatter_n(int n, const C& c, Args& ...args)

If n is less than sizeof...(args), returns zero, otherwise writes first elements of container to arguments and returns sizeof...(args).

template <class C, typename... Argsint scatter(const C& c, Args& ...args)

Same as scatter_n(c.size(), c, args...).

 Last edit by cxl on 08/16/2020. Do you want to contribute?. T++