about summary refs log tree commit diff
path: root/third_party/nix/src/libutil/visitor.hh
blob: bf1d665af77fa198ccf3cb9da955b46866cae9a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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