mirror of https://github.com/oxen-io/lokinet
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
815 B
C++
40 lines
815 B
C++
5 years ago
|
#ifndef LLARP_VARIANT_HPP
|
||
|
#define LLARP_VARIANT_HPP
|
||
|
|
||
|
#include <absl/types/variant.h>
|
||
|
|
||
|
namespace llarp
|
||
|
{
|
||
|
namespace util
|
||
|
{
|
||
|
template < typename... Ts >
|
||
|
struct _overloaded;
|
||
|
|
||
|
template < typename T, typename... Ts >
|
||
|
struct _overloaded<T, Ts...> : T, _overloaded<Ts...>
|
||
|
{
|
||
|
_overloaded(T&& t, Ts&&... ts) : T(t), _overloaded<Ts...>(std::forward<Ts>(ts)...) {}
|
||
|
using T::operator();
|
||
|
|
||
|
using _overloaded< Ts... >::operator();
|
||
|
};
|
||
|
|
||
|
template<typename T>
|
||
|
struct _overloaded<T> : T
|
||
|
{
|
||
|
_overloaded(T&& t) : T(t) {}
|
||
|
|
||
|
using T::operator();
|
||
|
};
|
||
|
|
||
|
template < typename... Ts >
|
||
|
constexpr auto overloaded(Ts&&... ts)->_overloaded< Ts... >
|
||
|
{
|
||
|
return _overloaded<Ts...>(std::forward<Ts>(ts)...);
|
||
|
}
|
||
|
|
||
|
} // namespace util
|
||
|
} // namespace llarp
|
||
|
|
||
|
#endif
|