Modern C++ generic header-only template library.

Overview

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"; });
Comments
  • Add conan package

    Add conan package

    I'm installing all my dependencies from conan, and could not find a conan package for nytl. I know it's only headers, but that doesn't mean it can't be distributed using conan :).

    opened by Alxandr 14
  • Adding conan packaging configuration

    Adding conan packaging configuration

    As discussed, this is it. The conan packaging configuration can be found in the /conan subdirectory. Locally, you can package the library like this:

    cd nytl/conan
    conan create nyorain/stable
    

    This will create the package nytl/[email protected]/stable

    If you would like to package a specific version, you need to change line 6 of conan/conanfile.py to version = "0.1" for example before executing the above mentioned command. In that case, the package signature will be nytl/[email protected]/stable

    To publish the package on bintray, you need to get an account there. Then, you create a conan repository on bintray. The repository will have a URL which you can find out by clicking on a "set me up" button that appears on its details. Before publishing, add this url to your conan instance using:

    conan remote add nyorainrepo http://myrepository

    Also before publishing, create an entry for the package in the conan repository on bintray, called nytl:nyorain (if you don't do that, you can still publish the package but you will have trouble updating its details. I think this is a bug or something). You can then publish it, using the following command:

    conan upload nytl/[email protected]/stable -r"nyorainrepo" --all

    Once the package is published, you can see online on its details a button which you can click on to request that it be included in the conan-center repository. That is a curated repository, of good quality packages, managed by the conan team. Make sure you mention that you are the library developer and you are not packaging somebody else's library. This will speed things up hopefully :)

    If you have any questions, let me know.

    opened by ghost 5
  • Provide SIMD support for matrices, vecs

    Provide SIMD support for matrices, vecs

    • will only be used if required headers/functionality is available (probably use of macros to determine whether to use them)
    • many operations (esp. vec operations) will work way faster with SIMD
    enhancement 
    opened by nyorain 1
  • Add simple utf helper templates/functions/classes

    Add simple utf helper templates/functions/classes

    • utf string size
    • integration with c++11 utf stl features (conversions, utf string literals)
    • some functionality for accessing chars (chars - NOT bytes) of a string
    • example reference: sfml
    enhancement 
    opened by nyorain 1
  • Use meson as build system; Rework vec/mat + callback

    Use meson as build system; Rework vec/mat + callback

    • Various bug and doc fixes
    • Removes cmake, only uses meson as build system
    • Splits callback into nytl::Callback and nytl::RecursiveCallback, fixes the recursive implementation (+ tests)
    • adds ci using travis
    • reworks vec/mat (+ ops) to be less generic (no longer split operations and storage/class since this does not always work) but more functional, better tested and with less bugs/overhead/complexity
    opened by nyorain 0
  • Reworked library, towards first release

    Reworked library, towards first release

    Big changes towards the first alpha release of nytl.

    • changed naming, all types begin now with a capital letter
    • added serialize/typemap/typeName support, closes #4
    • huge general improvements, more new features
    • experimental files are now on a separate branch, removed their folder
    • updated the README.md file, added some basic examples, WIP
    • added better explained examples in doc/examples
    • updated copyright everywhere
    • added some missing implementations or fixed existing ones (simplex algorithms)
    • added nytl::Any (custom impl if std::any is not available)
    • reworked nytl::transform classes and functions
    • still stuff to fix/implement/review
    opened by nyorain 0
  • Rework serialize and typemap to some kind of general dynamic typing

    Rework serialize and typemap to some kind of general dynamic typing

    Provide some general mechanism for serializing types and creating objects dynamically by something like a type-id, e.g. a string. Something like this:

    typedObject myVariable = nytl::types::create("int");
    

    Keeping it simple with less macros and fallback (with warnings?) to compiler-specific rtti.

    enhancement 
    opened by nyorain 0
  • Update documentation

    Update documentation

    • add documentation for all classes and functions
    • add examples
    • fix github desciptions, wiki and documentation pages
    • fix the doxygen/bootstrap design, pretty messed up at the moment:

    screenshot

    Hard to read/understand; fix margins and aligning

    enhancement 
    opened by nyorain 0
  • Essencially changed the major nytl-math classes

    Essencially changed the major nytl-math classes

    • introduced simplex and made triangle, line specializations of simplex (added tetrahedron as new spec.)
    • added linearSolver as utility file for solving linear equotations (has to be improved soon, bad performance, too complex)
    • srsly improved other classes, interface and bug fixes for e.g. mat or vec
    • introduced some other new files and specializations (e.g. for vec, seperated some parts into inline files)
    opened by nyorain 0
Releases(v0.6.0)
Owner
Jan
Jan
FSD-Template - A template UE4.25 project for BP modding.

FSD-Template Project generated by Archengius' UE4 Template Generator. Reflected C++ classes generated by CheatingMuppet & Archengius' UE4SS UHT Genera

null 16 Dec 29, 2022
Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags.

Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags. Quick start #include <bitflags/bitf

Marin Peko 76 Nov 22, 2022
expected lite - Expected objects in C++11 and later in a single-file header-only library

expected lite: expected objects for C++11 and later expected lite is a single-file header-only library for objects that either represent a valid value

Martin Moene 254 Jan 4, 2023
gsl-lite – A single-file header-only version of ISO C++ Guidelines Support Library (GSL) for C++98, C++11, and later

gsl-lite: Guidelines Support Library for C++98, C++11 up metadata build packages try online gsl-lite is an implementation of the C++ Core Guidelines S

gsl-lite 774 Jan 7, 2023
optional lite - A C++17-like optional, a nullable object for C++98, C++11 and later in a single-file header-only library

optional lite: A single-file header-only version of a C++17-like optional, a nullable object for C++98, C++11 and later Contents Example usage In a nu

Martin Moene 361 Dec 28, 2022
span lite - A C++20-like span for C++98, C++11 and later in a single-file header-only library

span lite: A single-file header-only version of a C++20-like span for C++98, C++11 and later Contents Example usage In a nutshell License Dependencies

Martin Moene 427 Dec 31, 2022
string_view lite - A C++17-like string_view for C++98, C++11 and later in a single-file header-only library

string_view lite: A single-file header-only version of a C++17-like string_view for C++98, C++11 and later Contents Example usage In a nutshell Licens

Martin Moene 357 Dec 28, 2022
variant lite - A C++17-like variant, a type-safe union for C++98, C++11 and later in a single-file header-only library

variant lite: A single-file header-only version of a C++17-like variant, a type-safe union for C++98, C++11 and later Contents Example usage In a nuts

Martin Moene 225 Dec 29, 2022
gsl-lite – A single-file header-only version of ISO C++ Guidelines Support Library (GSL) for C++98, C++11, and later

gsl-lite: Guidelines Support Library for C++98, C++11 up metadata build packages try online gsl-lite is an implementation of the C++ Core Guidelines S

gsl-lite 772 Dec 31, 2022
Bsl - Rust 2018 and C++20, "constexpr everything", AUTOSAR compliant header-only library intended to support the development of critical systems applications

Description The Bareflank Support Library (BSL) is a Rust 2018 and C++20, "constexpr everything", AUTOSAR compliant header-only library intended to su

Bareflank 76 Dec 8, 2022
A header-only, unobtrusive, almighty alternative to the C++ switch statement that looks just like the original.

uberswitch A header-only, unobtrusive, almighty alternative to the C++ switch statement that looks just like the original. Sample usage (incomplete -

Fabio 85 Jan 3, 2023
EASTL stands for Electronic Arts Standard C++ Template Library

EASTL stands for Electronic Arts Standard Template Library. It is an extensive and robust implementation that has an emphasis on high performance.

Electronic Arts 6.9k Dec 27, 2022
RTL - Reactive Template Library for C++

RTL - Reactive Template Library It solves all my C++ animation problems -- me Using RTL Lazy, caching, reactive variables

Lorents Odin Gravås 3 Dec 22, 2021
A template C project using CMAKE, logging library and basic memory handling.

C Project template Aim of this Repository is to create a template repository for C executable projects with following properties: Cmake project Loggin

Aditya Singh Rathore 6 May 23, 2022
STXXL: Standard Template Library for Extra Large Data Sets

STXXL is an implementation of the C++ standard template library STL for external memory (out-of-core) computations

STXXL 437 Dec 24, 2022
this lib with 26 template container and 10 kinds of algorithm, it is a good lib for study and usage

simple stl this lib simplify the achievement detail of common container, but add the container variety, the whole code partily follow Google Style. Em

wujiazheng 7 Mar 10, 2022
This is the template for peripheral projects using nRF5 SDK

NRF5_SDK template project About This is the template for peripheral projects using nRF5 SDK Getting Started To get a local copy up and running follow

Tai Nguyen 1 Nov 27, 2021
Code::Blocks template for custom launcher executable.

Launcher Code::Blocks template for custom launcher executables. This is a basic Code::Blocks project for creating authentic Windows executables. Inclu

Federico Cappelletti 1 Feb 5, 2022
Library that simplify to find header for class from STL library.

Library that simplify to find header for class from STL library. Instead of searching header for some class you can just include header with the class name.

null 6 Jun 7, 2022