Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
SimpleStorage::overloaded< TSelector > Struct Template Reference

#include <simple_storage.h>

Inheritance diagram for SimpleStorage::overloaded< TSelector >:
[legend]

Detailed Description

template<class... TSelector>
struct SimpleStorage::overloaded< TSelector >

The storage is working with something called an invariant. An invariant is something we can see as a tagged union of sorts but a bit different. An invariant is essentially a type that says "I can be any of the following types". We know this from discriminated unions used in F# or free unions from TypeScript.

The overloaded struct is a trick that basically boils down to the following: "Be a structure that overloads the call type for anything that is inside of you".

In our case, its type may as well just be: struct overloaded { int operator()(int); bool operator()(bool); std::string operator()(std::string); }

We just use templates to generate this type for us based on the shape of the invariant passed, that is all. In C++ 26 we have this type included in the base library. We have to write it manually here.


The documentation for this struct was generated from the following file: