qxLib
qx::visit_overload< args_t > Struct Template Reference

#include <type_traits.h>

Inheritance diagram for qx::visit_overload< args_t >:

Detailed Description

template<class... args_t>
struct qx::visit_overload< args_t >

This struct allows to visit std::variant with lambdas

Note
https://www.cppstories.com/2018/09/visit-variants/
Template Parameters
args_t- lambda types
struct Fluid { };
struct LightItem { };
struct HeavyItem { };
struct FragileItem { };
int main() {
std::variant<Fluid, LightItem, HeavyItem, FragileItem> package;
std::visit(qx::visit_overload
{
[](const Fluid& ) { std::cout << "fluid\n"; },
[](const LightItem& ) { std::cout << "light item\n"; },
[](const auto&) { std::cout << "default\n"; }
},
package);
}

Definition at line 134 of file type_traits.h.


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