|
nkr
A C++20 library with a custom meta-programming language.
|
The entire library is contained within this namespace. More...
Namespaces | |
| namespace | allocator |
| Allocator types are used by other types to allocate and deallocate various kinds of memory. | |
| namespace | array |
| Array types are used to represent multiple values of the same type in various ways and locations. | |
| namespace | boolean |
| Boolean types are used to represent one of two values, and never any more than two. | |
| namespace | charcoder |
| Charcoder types are used to represent and work with specific character encodings. | |
| namespace | concurrency |
| Concurrency types are used to make other types work in a concurrent or parallel context. | |
| namespace | constant |
| Constant types are used to represent values that cannot be changed. | |
| namespace | constant_t$ |
| The private namespace of nkr::constant_t. | |
| namespace | cpp |
| CPP types are standard C++ types that can be used like other nkr types. | |
| namespace | enumeration |
| Enumeration types provide abstractions over the basic C and C++ enums, making them fully usable types. | |
| namespace | error |
| Error types provide an abstraction over enumerations representing runtime recoverable errors. | |
| namespace | interface |
| Interfaces provide a small abstraction over different entities so that they can be utilized in the same way. | |
| namespace | negatable |
| Negatable types are used to represent numbers that can be negated, i.e. set to a negative number. | |
| namespace | none |
| None types are used to represent the concept of nothing. | |
| namespace | os |
| OS contains functionality supplied through a thin abstraction over the underlying operating system. | |
| namespace | positive |
| Positive types are used to represent numbers that are only ever positive and cannot be negated. | |
Classes | |
| class | constant_t |
| Represents an immutable literal value in a compile-time or run-time context. More... | |
| class | constant_tg |
| The identity type tag for nkr::constant_t. More... | |
| class | constant_ttg |
| The identity template tag for nkr::constant_t. More... | |
Concepts | |
| concept | constant_tr |
| The identity type trait for nkr::constant_t. | |
| concept | constant_ttr |
| The identity template trait for nkr::constant_t. | |
| concept | constant_of_tr |
| The identity inner type trait for nkr::constant_t. | |
| concept | tr |
| Used to filter a type by its qualifications, and by other types, templates, identities, and generics in the context of a declaration. | |
Typedefs | |
| template<typename type_p > | |
| using | t = nkr::tr$::ts< AND_tg, nkr::tuple::types_t< type_p > > |
| A way to wrap a single type for use with an nkr::TR expression, to differentiate it from a template. More... | |
| template<nkr::generic::tag::logic_gate_tr operator_p, typename ... types_p> | |
| using | ts = nkr::tr$::ts< operator_p, nkr::tuple::types_t< types_p... > > |
| A way to parenthesize and perform logical operations on several types in an nkr::TR expression. More... | |
| template<template< typename ... > typename template_p> | |
| using | tt = nkr::tr$::tts< AND_tg, nkr::tuple::templates_t< template_p > > |
| A way to wrap a single template for use with an nkr::TR expression, to differentiate it from a type. More... | |
| template<nkr::generic::tag::logic_gate_tr operator_p, template< typename ... > typename ... templates_p> | |
| using | tts = nkr::tr$::tts< operator_p, nkr::tuple::templates_t< templates_p... > > |
| A way to parenthesize and perform logical operations on several templates in an nkr::TR expression. More... | |
Functions | |
| template<nkr::ts_tr subjects_p, typename ... expression_parts_p> | |
| constexpr nkr::boolean::cpp_t | TR () noexcept |
| Used to filter a type by its qualifications, and by other types, templates, identities, and generics. More... | |
The entire library is contained within this namespace.
The three letters nkr make up my initials. Inspiried by Sean T. Barrett's stb library, I named this library after myself for two reasons:
| using nkr::t = typedef nkr::tr$::ts<AND_tg, nkr::tuple::types_t<type_p> > |
A way to wrap a single type for use with an nkr::TR expression, to differentiate it from a template.
| using nkr::ts = typedef nkr::tr$::ts<operator_p, nkr::tuple::types_t<types_p...> > |
A way to parenthesize and perform logical operations on several types in an nkr::TR expression.
| using nkr::tt = typedef nkr::tr$::tts<AND_tg, nkr::tuple::templates_t<template_p> > |
A way to wrap a single template for use with an nkr::TR expression, to differentiate it from a type.
| using nkr::tts = typedef nkr::tr$::tts<operator_p, nkr::tuple::templates_t<templates_p...> > |
A way to parenthesize and perform logical operations on several templates in an nkr::TR expression.
|
constexprnoexcept |
Used to filter a type by its qualifications, and by other types, templates, identities, and generics.
An integral function for the entire library. Any type or template that satisfies the nkr::interface::type_i or nkr::interface::template_i respectively can be used in conjunction with pre-defined operators to form an expression for use with this function. Input a group of subjects in addition to your arbitrary-length expression, and a compile-time or runtime boolean will be output indicating whether or not the subjects satisfy the expression.
subject, and an arbitrary number of operators paired with an operand: int is any int. This time without comments: type. This syntactical addition to a nkr::TR expression allows for two powerful distinctions to occur, both of which we will learn in more detail below.subject and an operator without using an operand. This trivial example will always return true because any subject will always be any subject: any_tg. How else would we constrain a subject to a qualification regardless of type?: any operators is that any_const_tg will work with a volatile type as long as it's also const, and the any_volatile_tg with a const type, as long as it's also volatile: any_qualified_tg merely requires that a type have any qualification: any_non_qualified_tg will only allow types without qualification: any_non_const_tg and any_non_volatile_tg to help you explictly declare not only how to constrain the subjects of your nkr::TR expressions, but quite literally to declare the intent of your constraint in reasonably plain English.just_tg does just that: just_tg that allow for exactitude through use of the operator, as opposed to the operand: just_tg but entirely ignored for any of the variant operators: just_tg allows for the standard combination of qualifications, even with the hidden qualification of an alias: just_tg for the sake of simplicity: true because nkr::pointer::cpp_t<int> is an alias of int*: inner type which would be int in this case. This allows for more flexible expressions that make use of more than just the any_tg operator. Here we are asserting the same as above, that int* is any nkr::pointer::cpp_t of any int: ttg, that is a template tag of nkr::pointer::cpp_t to achieve the same result: tags can bring even more flexibility to an expression. For example, most templates provide a tag to test if a type is instantiated from it, regardless of the subject's actual inner type. Below we simply assert that the subject needs to be instantiated from any nkr::pointer::cpp_t by use of its tg or type tag: tt with ttg to constrain a template tag and t with tg to constrain a type tag.type or types respectively. This syntactical feature differentiates between using a singluar type or multiple types in a subject or operand. It also differentiates between using types or templates as an operand. To use templates as an operand you would use nkr::tt or nkr::tts, that is 'template type' or 'template types' respectively. It is necessary to wrap the templates this way for the sake of arbitrary length expressions, which cannot be made up of both types and templates but only one or the other.Tags become absolutely critical when we start to introduce generics into our expressions.inner type is const. It only cares that it is a reference to a pointer that is non_const, else it wouldn't be able to set it. It doesn't actualy care if the pointer is volatile or not because its functionality remains the same in that event.type tag representing a template.t for type and tt for template of type, we also likewise use nkr::tts instead of nkr::ts to make use of multiple templates in an operand: