-
Notifications
You must be signed in to change notification settings - Fork 3
Home
veg
is a c++ utility library with some commonly used vocabulary types, functional utilities, assertion macros and basic struct reflection.
- correctness
- compile time and runtime performance
- noexcept correctness
- being sfinae friendly and providing friendly diagnostics
- abi stability
- api stability (until 1.0)
- compatibility with standard library beyond what is provided for other types. i'm not opposed to the idea, it's just a bunch of work
#include <veg/type_traits/...>
concept-like type traits
#include <veg/util/assert.hpp>
provides pretty assertion macros that do basic expression decomposition. example:
#include <veg/util/assert.hpp>
int main() {
int x = 2;
int y = 3;
VEG_ASSERT(x == y);
}
displays this error message (function parsing currently only supported on recent versions of clang and gcc, and doesn't handle all the cases correctly)
1 assertion failed
in function:
int main()
a.cpp:6:
fn main()
returns: int
fatal assertion `x == y' failed:
assertion expands to: `2 == 3'
terminate called without an active exception
[1] 27979 IOT instruction (core dumped) ./a.out
#include <veg/util/index.hpp>
defines isize
constant indexing types Fix<N>
, a dynamic one Dyn
, and provides user defined literals for creating them. (e.g., 1_v => Dyn{1}
, 2_c => Fix<2>{}
)
the compile-time constants are used for index accessing in Tuple
and Uwunion
#include <veg/util/dbg.hpp>
provides a function for pretty debug printing of various classes. supports primitives veg
's vocabulary types, also allows for customization in order to support user defined types. also interoperates with reflection
#include <veg/util/compare.hpp>
todo!()
#include <veg/tuple.hpp>
lightweight product type. also supports structured bindings
example:
#include <veg/tuple.hpp>
using namespace veg;
auto main() -> int {
Tuple<int, float> t;
t[0_c] = 13;
t[1_c] = 3.5F;
dbg(t); // prints { 13, +3.5000e+00, }
}
#include <veg/uwunion.hpp>
lightweight(ish) sum type. example:
#include <veg/uwunion.hpp>
using namespace veg;
auto main() -> int {
Uwunion<int, float> u(0_c, 3); // int is the active member
t[0_c] = 13;
dbg(t); // prints 13
t.emplace(1_c, 3.5);
dbg(t); // prints +3.5000e+00
t[0_c]; // inactive member access is a runtime error
}
todo!()
todo!()