UgMisc
A miscellaneous header-only C++ library, compatible with C++17 and later standards.
Even though the headers work with C++17, they will use C++20 concepts if they are available, so that compiler error messages will be clearer.
The repository is currently hosted at codeberg.org.
Overview
Utilities provided include:
-
Manipulate lists of types. Concatenate, take strided subarrays, apply metafunctions to each type, etc.
-
Find integers which can encode a set of values, according to flags indicating how signed or unsigned types should be selected. Can easily work with custom integer classes, and supports the standard ones (uint8_t, int16_t, etc) out of the box.
-
C++20 style bit operations, like count left zeros, are supported in C++17, using bit mask operations.
Calls to the bit op functions will forward to the standard library functions if they exist, and fall back to using bitwise ANDs otherwise. The fallback function works with anything that acts enough like a radix-2 unsigned integer and has a std::numeric_limits specialisation.
-
Search through a list of types or objects for a named member. Works for typedefs and for static and non-static data members and methods, including overloaded methods. See the example below.
#include <ugmisc/member>
UGMISC_DECL_MEMBER_ACCESS(Foo, foo); // Declares Foo.
// Foo is a type that searches for members named "foo".
using F = ugmisc::static_member_caller<Foo, X, Y, Z>;
F::call(args...); // Error if none of X, Y, Z has a static method called "foo" that can be called this way.
// Instances of F are callable.
F f;
f.call(args...); // Same as F::call(args...).
f(args...); // Same as F::call(args...).
// Default value:
// The following two expressions are equivalent.
F::fallback( func )(args...);
f.fallback( func )(args...);In the fallback example above, the first valid expression is evaluated:
X::foo(args...)std::invoke(X::foo, args...)Y::foo(args...)std::invoke(Y::foo, args...)Z::foo(args...)std::invoke(Z::foo, args...)func(args...)std::invoke(func, args...)func()
Documentation
- Ugmisc HEAD, English
- UgMisc Version 0.3, English
- UgMisc Version 0.2, English
- UgMisc Version 0.1, English
Files
For tagged releases, the source is available in tar.xz and zip archives, along with a Meson wrap file. There is a file containing digests of these files, and the digests file is signed using the same OpenPGP key used to sign commits in the repository.
The files are hosted at Codeberg.