|
nkr
A C++20 library with a custom meta-programming language.
|
Interfaces provide a small abstraction over different entities so that they can be utilized in the same way. More...
Namespaces | |
| namespace | none |
| None interfaces handle semantics revolving around the lack of something. | |
Interfaces provide a small abstraction over different entities so that they can be utilized in the same way.
Interfaces are usually introduced when working with generics so that syntactically different entities that are otherwise semantically similar or equivalent can be treated with the same syntax. Put another way, interfaces help to avoid unnecessary constraints on program design and thus directly increase the robustness of code.
For example, nkr::interface::none::value_i can return a none value for a type that doesn't have a default constructor or for a type that does have a default constructor but which doesn't default its type instances to a value that can be equated to none. Importantly, because this interface must be opted into, this allows the designer of an entity to avoid having to fulfill the concept of none when it doesn't make sense, or if they simpy want to avoid using the concept of none according to design principles. For a concrete example, please see nkr::interface::none::value_i.
There is a cost to using interfaces and it is two fold: