diff --git a/third_party/nix/src/libutil/CMakeLists.txt b/third_party/nix/src/libutil/CMakeLists.txt index 43b9e8525..a9736b37b 100644 --- a/third_party/nix/src/libutil/CMakeLists.txt +++ b/third_party/nix/src/libutil/CMakeLists.txt @@ -25,6 +25,7 @@ set(HEADER_FILES thread-pool.hh types.hh util.hh + visitor.hh xml-writer.hh ) diff --git a/third_party/nix/src/libutil/visitor.hh b/third_party/nix/src/libutil/visitor.hh new file mode 100644 index 000000000..bf1d665af --- /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 +struct overloaded : Ts... { + using Ts::operator()...; +}; + +template +overloaded(Ts...) -> overloaded; + +} // namespace nix::util