Sen API
Sen Libraries
Loading...
Searching...
No Matches
sen::Overloaded< Ts > Struct Template Reference

Helper type for std::variant lambda visitors. More...

#include <class_helpers.h>

Inheritance diagram for sen::Overloaded< Ts >:

Detailed Description

template<class... Ts>
struct sen::Overloaded< Ts >

Helper type for std::variant lambda visitors.

Example:

std::visit(
sen::Overloaded {[&](uint8_t val) { ... },
[&](int16_t val) { ... },
[&](uint16_t val) { ... },
[&](int32_t val) { ... },
[&](uint32_t val) { ... },
[&](int64_t val) { ... },
[&](uint64_t val) { ... },
[&](float32_t val) { ... },
[&](float64_t val) { ... }},
variant);
};
float float32_t
Definition numbers.h:16
double float64_t
Definition numbers.h:17
Helper type for std::variant lambda visitors.
Definition class_helpers.h:170

You need to handle all the cases for it to compile. You can also use auto if you need to generalize it:

std::visit(
sen::Overloaded {[&](uint8_t val) { doThis(val); },
[&](int16_t val) { doThat(val); },
[&](auto val) { doSomethingElse(val); }},
variant);
}

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