diff options
Diffstat (limited to 'third_party/nix/src/libutil/visitor.hh')
-rw-r--r-- | third_party/nix/src/libutil/visitor.hh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/third_party/nix/src/libutil/visitor.hh b/third_party/nix/src/libutil/visitor.hh new file mode 100644 index 000000000000..bf1d665af77f --- /dev/null +++ b/third_party/nix/src/libutil/visitor.hh @@ -0,0 +1,19 @@ +#pragma once + +namespace nix::util { + +// Helper class used for visiting std::variants by creating a variadic +// list of lambda expressions that delegates calls to each of the +// callables. +// +// See e.g. +// https://dev.to/tmr232/that-overloaded-trick-overloading-lambdas-in-c17 +template <class... Ts> +struct overloaded : Ts... { + using Ts::operator()...; +}; + +template <class... Ts> +overloaded(Ts...) -> overloaded<Ts...>; + +} // namespace nix::util |