mirror of
https://github.com/jslightham/cpp-utils.git
synced 2026-03-09 18:12:26 +01:00
Initial commit
This commit is contained in:
23
Variant.h
Normal file
23
Variant.h
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
// Helper to make it easier to use std::visit with std::variant
|
||||
// For example,
|
||||
// std::visit(
|
||||
// overloaded{
|
||||
// [](int i) { std::cout << "int: " << i << std::endl; },
|
||||
// [](double d) { std::cout << "double: " << d << std::endl; },
|
||||
// },
|
||||
// variant
|
||||
// );
|
||||
|
||||
#ifndef VARIANT_H
|
||||
#define VARIANT_H
|
||||
|
||||
#include <variant> // NOLINT
|
||||
|
||||
template <class... Ts> struct overloaded : Ts... {
|
||||
using Ts::operator()...;
|
||||
};
|
||||
|
||||
template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
|
||||
|
||||
#endif // VARIANT_H
|
||||
Reference in New Issue
Block a user