All Projects → nyorain → Nytl

nyorain / Nytl

Licence: bsl-1.0
Modern C++ generic header-only template library.

Projects that are alternatives of or similar to Nytl

Generic Auto Updater
Generic Auto-Updater: a robust, user-friendly, clean and efficient Auto-Updater to maintain any client patched.
Stars: ✭ 95 (+9.2%)
Mutual labels:  generic, template
Eval
Eval is a lightweight interpreter framework written in Swift, evaluating expressions at runtime
Stars: ✭ 157 (+80.46%)
Mutual labels:  generic, template
Dot Github
.github directory generator
Stars: ✭ 237 (+172.41%)
Mutual labels:  utility, template
Webhook Discord
A simple Javascript file for nicely formatting Discord webhooks
Stars: ✭ 81 (-6.9%)
Mutual labels:  utility
Vuetemplate
vue模板,集成常用组件
Stars: ✭ 81 (-6.9%)
Mutual labels:  template
Tongjithesis
同济大学本科毕业设计LaTeX模板 LaTeX template for Tongji Undergaduate Thesis
Stars: ✭ 85 (-2.3%)
Mutual labels:  template
Gomplate
A flexible commandline tool for template rendering. Supports lots of local and remote datasources.
Stars: ✭ 1,270 (+1359.77%)
Mutual labels:  template
Ring Buffer
simple C++11 ring buffer implementation, allocated and evaluated at compile time
Stars: ✭ 80 (-8.05%)
Mutual labels:  template
Binary
Generic and fast binary serializer for Go
Stars: ✭ 86 (-1.15%)
Mutual labels:  generic
Gdash
A functional utility library for GML/GameMaker: Studio - partials, map/reduce and more
Stars: ✭ 83 (-4.6%)
Mutual labels:  utility
Butterfly
🔥 蝴蝶--【简单】【稳定】【好用】的 Python web 框架🦋 除 Python 2.7,无其他依赖; 🦋 butterfly 是一个 RPC 风格 web 框架,同时也是微服务框架,自带消息队列通信机制实现分布式
Stars: ✭ 82 (-5.75%)
Mutual labels:  template
Perun
A command-line validation tool for AWS Cloud Formation that allows to conquer the cloud faster!
Stars: ✭ 82 (-5.75%)
Mutual labels:  template
Swift Project Template
🍪 Easily generate Swift projects with Cookiecutter
Stars: ✭ 85 (-2.3%)
Mutual labels:  template
Aura.view
Provides TemplateView and TwoStepView using PHP as the templating language, with support for partials, sections, and helpers.
Stars: ✭ 81 (-6.9%)
Mutual labels:  template
Boilr
⚡️ boilerplate template manager that generates files or directories from template repositories
Stars: ✭ 1,268 (+1357.47%)
Mutual labels:  template
Framework7 Template Vue Simple
Deprecated! Simple Framework7 Vue starter app template in a single HTML file
Stars: ✭ 81 (-6.9%)
Mutual labels:  template
Simple Reactjs App
Simple Application Using Basic React Components and Communication between them
Stars: ✭ 86 (-1.15%)
Mutual labels:  template
Template Mustache
Drawing Mustaches on Perl, for fun and profit
Stars: ✭ 82 (-5.75%)
Mutual labels:  template
Is
Simple type checking.
Stars: ✭ 82 (-5.75%)
Mutual labels:  utility
Jupytemplate
Templates for jupyter notebooks
Stars: ✭ 85 (-2.3%)
Mutual labels:  template

nytl

A lightweight and generic header-only template library for C++17. Includes various utility of all kind that i needed across multiple projects:

  • Extremely lightweight vector and matrix templates
    • Basically just std::array with mathematical vector/matrix semantics
    • Additionally various useful operations (mat | vec)
  • Simple utf conversion and utf8 parsing helpers: nytl/utf.hpp
  • A Callback implementation for high-level and fast function callbacks.
  • Easily make virtual classes cloneable: nytl/clone.hpp
  • Pseudo-RAII handling with scope guards: nytl/scope.hpp
  • Lightweight and independent span template: nytl/span.hpp
  • Combining c++ class enums into flags: nytl/flags.hpp

All headers were written as modular, independent and generic as possible. Most utilities can be used indenpendently from each other. The only required dependency is a compiler supporting full C++17 and its stl (this means no suppport for msvc at the moment). All files are licensed under the Boost License.

Contributing

Contributions to library, tests, documentation, examples as well as all suggestions and ideas are always appreciated. Just start a pull request or an issue on github.

Using nytl

There are multiple ways to use nytl. Either install all of its headers on your system and make sure the install path can be found by the compiler. If you need just a few header files (or even just a few functions), just copy those files into your project folder. It can also be used as meson subproject.

Remember that nytl requires a solid C++17 compiler, only recent versions of gcc and clang are tested. Below some basic code examples for (only a) few nytl features to give you an idea.

nytl::Callback and nytl::RecursiveCallback

Callbacks mirror the signal/slot principle in modern c++ with many useful features. For the full documentation, see nytl/callback.hpp. If you want to modify (call/register/disconnect) the callback from within a handler, see nytl/recursiveCallback.hpp.

// Example callback
auto onEvent = nytl::RecursiveCallback<void()> {};

// Adds a callback listener
auto connection = onEvent.add([]{ std::cout << "called\n"; });
connection.disconnect(); // unregisters the listener

onEvent = &foo; // sets foo as only listener
onEvent += []{}; // same as onEvent.add

// listener functions can also take an additional Connection argument that
// allows them to unregister themself from within the listener
onEvent += [&](nytl::Connection selfConnection) {
	selfConnection.disconnect(); // will unregister itself on first call
	onEvent += &bar; // one can also add new listeners from inside a listener
};

onEvent(); // calls all registered listener functions
onEvent.call(); // can also be done more explicit

nytl::ScopeGuard

ScopeGuards are another utility concept implemented by nytl. The mirror finally syntax from other languages and allow safe RAII-like handling of non-RAII resources. For the full documentation, see nytl/scope.hpp.

// open a file descriptor we want to close later on
auto fd = ::open("test.txt");

// create a scope guard that will execute the passed functions as soon
// as this scope is left, no matter in which way. Makes closing the fd
// exception safe and also more maintainable since early returns can be
// added without having to care about the fd.
auto fdGuard = nytl::ScopeGuard([&]{ ::close(fd); })

// there are also classes that only execute the passed functions if the
// scope was left normally or due to an exception
auto successGuard = nytl::SuccessGuard([&]{ std::cout << "scope left normally\n"; });
auto exceptionGuard = nytl::ExceptionGuard([&]{ std::cout << "exception thrown\n"; });
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].