diff --git a/src/libcmd/built-path.cc b/src/libcmd/built-path.cc index 6ff99070d..c4f8adf78 100644 --- a/src/libcmd/built-path.cc +++ b/src/libcmd/built-path.cc @@ -1,6 +1,7 @@ #include "built-path.hh" #include "derivations.hh" #include "store-api.hh" +#include "overloaded.hh" #include diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc index de9f546fc..77f353d1f 100644 --- a/src/libcmd/command.cc +++ b/src/libcmd/command.cc @@ -5,6 +5,7 @@ #include "nixexpr.hh" #include "profiles.hh" #include "repl.hh" +#include "overloaded.hh" #include diff --git a/src/libcmd/installable-attr-path.cc b/src/libcmd/installable-attr-path.cc index 06e507872..789fa7903 100644 --- a/src/libcmd/installable-attr-path.cc +++ b/src/libcmd/installable-attr-path.cc @@ -16,6 +16,7 @@ #include "url.hh" #include "registry.hh" #include "build-result.hh" +#include "overloaded.hh" #include #include diff --git a/src/libcmd/installable-derived-path.cc b/src/libcmd/installable-derived-path.cc index 4d1f83a1c..206cbb224 100644 --- a/src/libcmd/installable-derived-path.cc +++ b/src/libcmd/installable-derived-path.cc @@ -1,5 +1,6 @@ #include "installable-derived-path.hh" #include "derivations.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libcmd/installable-flake.cc b/src/libcmd/installable-flake.cc index bb75b8ff0..003b9a80c 100644 --- a/src/libcmd/installable-flake.cc +++ b/src/libcmd/installable-flake.cc @@ -17,6 +17,7 @@ #include "url.hh" #include "registry.hh" #include "build-result.hh" +#include "overloaded.hh" #include #include diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc index 973db62b0..a215f81c0 100644 --- a/src/libcmd/installables.cc +++ b/src/libcmd/installables.cc @@ -20,6 +20,7 @@ #include "url.hh" #include "registry.hh" #include "build-result.hh" +#include "overloaded.hh" #include #include diff --git a/src/libexpr/eval-cache.cc b/src/libexpr/eval-cache.cc index 20dd9e0bc..3599bacbf 100644 --- a/src/libexpr/eval-cache.cc +++ b/src/libexpr/eval-cache.cc @@ -3,6 +3,7 @@ #include "eval.hh" #include "eval-inline.hh" #include "store-api.hh" +#include "overloaded.hh" namespace nix::eval_cache { diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index bef0effb6..ac42405e8 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -19,6 +19,7 @@ #include "fetch-to-store.hh" #include "flake/flakeref.hh" #include "parser-tab.hh" +#include "overloaded.hh" #include #include diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 72e98f6bb..a698130f9 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -8,6 +8,7 @@ #include "fetchers.hh" #include "finally.hh" #include "fetch-settings.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libexpr/parser-state.hh b/src/libexpr/parser-state.hh index 3305e05b6..426ece9aa 100644 --- a/src/libexpr/parser-state.hh +++ b/src/libexpr/parser-state.hh @@ -2,6 +2,7 @@ ///@file #include "eval.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 77601e457..7672092aa 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -15,6 +15,7 @@ #include "value-to-xml.hh" #include "primops.hh" #include "fetch-to-store.hh" +#include "overloaded.hh" #include #include diff --git a/src/libexpr/primops/context.cc b/src/libexpr/primops/context.cc index 1eec8b316..3e42e3efd 100644 --- a/src/libexpr/primops/context.cc +++ b/src/libexpr/primops/context.cc @@ -2,6 +2,7 @@ #include "eval-inline.hh" #include "derivations.hh" #include "store-api.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libexpr/value/context.cc b/src/libexpr/value/context.cc index 22361d8fa..5c554aa96 100644 --- a/src/libexpr/value/context.cc +++ b/src/libexpr/value/context.cc @@ -1,4 +1,5 @@ #include "value/context.hh" +#include "overloaded.hh" #include diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc index 481cb76e8..758a518af 100644 --- a/src/libstore/build/derivation-goal.cc +++ b/src/libstore/build/derivation-goal.cc @@ -13,6 +13,7 @@ #include "topo-sort.hh" #include "callback.hh" #include "local-store.hh" // TODO remove, along with remaining downcasts +#include "overloaded.hh" #include #include diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc index ef170d815..ad926bdd1 100644 --- a/src/libstore/build/local-derivation-goal.cc +++ b/src/libstore/build/local-derivation-goal.cc @@ -16,6 +16,7 @@ #include "cgroup.hh" #include "personality.hh" #include "namespaces.hh" +#include "overloaded.hh" #include #include diff --git a/src/libstore/build/worker.cc b/src/libstore/build/worker.cc index 83167b0f3..96ac46cba 100644 --- a/src/libstore/build/worker.cc +++ b/src/libstore/build/worker.cc @@ -5,6 +5,7 @@ #include "local-derivation-goal.hh" #include "signals.hh" #include "hook-instance.hh" +#include "overloaded.hh" #include diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc index 77f23b0b3..d73c97c1d 100644 --- a/src/libstore/content-address.cc +++ b/src/libstore/content-address.cc @@ -1,6 +1,7 @@ #include "args.hh" #include "content-address.hh" #include "split.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index 1181cc9e5..ddab1c092 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -13,6 +13,7 @@ #include "archive.hh" #include "derivations.hh" #include "args.hh" +#include "overloaded.hh" namespace nix::daemon { diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index ab84255d3..e3627239d 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -8,6 +8,7 @@ #include "common-protocol.hh" #include "common-protocol-impl.hh" #include "fs-accessor.hh" +#include "overloaded.hh" #include #include diff --git a/src/libstore/derived-path-map.cc b/src/libstore/derived-path-map.cc index 5982c04b3..9b1e86601 100644 --- a/src/libstore/derived-path-map.cc +++ b/src/libstore/derived-path-map.cc @@ -1,4 +1,5 @@ #include "derived-path-map.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libstore/derived-path.cc b/src/libstore/derived-path.cc index 214caab54..e9a9d010c 100644 --- a/src/libstore/derived-path.cc +++ b/src/libstore/derived-path.cc @@ -1,5 +1,6 @@ #include "derived-path.hh" #include "store-api.hh" +#include "overloaded.hh" #include diff --git a/src/libstore/downstream-placeholder.cc b/src/libstore/downstream-placeholder.cc index 7e3f7548d..ec4fd7576 100644 --- a/src/libstore/downstream-placeholder.cc +++ b/src/libstore/downstream-placeholder.cc @@ -1,5 +1,6 @@ #include "downstream-placeholder.hh" #include "derivations.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc index be442036d..03ebbe300 100644 --- a/src/libstore/legacy-ssh-store.cc +++ b/src/libstore/legacy-ssh-store.cc @@ -10,6 +10,7 @@ #include "ssh.hh" #include "derivations.hh" #include "callback.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index c8f194b92..1544fead9 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -11,6 +11,7 @@ #include "signals.hh" #include "finally.hh" #include "compression.hh" +#include "overloaded.hh" #include #include diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index c8646083b..101b8b186 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -8,6 +8,7 @@ #include "callback.hh" #include "closure.hh" #include "filetransfer.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libstore/outputs-spec.cc b/src/libstore/outputs-spec.cc index 21c069223..2cbc7ad81 100644 --- a/src/libstore/outputs-spec.cc +++ b/src/libstore/outputs-spec.cc @@ -5,6 +5,7 @@ #include "regex-combinators.hh" #include "outputs-spec.hh" #include "path-regex.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libstore/path-info.cc b/src/libstore/path-info.cc index 336a9fcfc..44b66ba13 100644 --- a/src/libstore/path-info.cc +++ b/src/libstore/path-info.cc @@ -1,5 +1,6 @@ #include "path-info.hh" #include "store-api.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libstore/path-with-outputs.cc b/src/libstore/path-with-outputs.cc index af6837370..a15f8e953 100644 --- a/src/libstore/path-with-outputs.cc +++ b/src/libstore/path-with-outputs.cc @@ -1,5 +1,6 @@ #include "path-with-outputs.hh" #include "store-api.hh" +#include "overloaded.hh" #include diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index e558c52e2..2d4d7c016 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -17,6 +17,7 @@ #include "logging.hh" #include "callback.hh" #include "filetransfer.hh" +#include "overloaded.hh" #include namespace nix { diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 94202d46e..94bc44e35 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -15,6 +15,7 @@ // FIXME this should not be here, see TODO below on // `addMultipleToStore`. #include "worker-protocol.hh" +#include "overloaded.hh" #include #include diff --git a/src/libstore/worker-protocol.cc b/src/libstore/worker-protocol.cc index ad94c79ee..d1abe49e3 100644 --- a/src/libstore/worker-protocol.cc +++ b/src/libstore/worker-protocol.cc @@ -7,6 +7,7 @@ #include "worker-protocol-impl.hh" #include "archive.hh" #include "path-info.hh" +#include "overloaded.hh" #include diff --git a/src/libutil/overloaded.hh b/src/libutil/overloaded.hh new file mode 100644 index 000000000..0adc41005 --- /dev/null +++ b/src/libutil/overloaded.hh @@ -0,0 +1,17 @@ +#pragma once + +namespace nix { + +/** + * C++17 std::visit boilerplate + */ +template +struct overloaded : Ts... +{ + using Ts::operator()...; +}; + +template +overloaded(Ts...) -> overloaded; + +} diff --git a/src/libutil/position.cc b/src/libutil/position.cc index 724e560b7..075c9f740 100644 --- a/src/libutil/position.cc +++ b/src/libutil/position.cc @@ -1,4 +1,5 @@ #include "position.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 860ddae06..0216fc019 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -880,13 +880,6 @@ constexpr auto enumerate(T && iterable) } -/** - * C++17 std::visit boilerplate - */ -template struct overloaded : Ts... { using Ts::operator()...; }; -template overloaded(Ts...) -> overloaded; - - std::string showBytes(uint64_t bytes); diff --git a/src/nix/app.cc b/src/nix/app.cc index 34fac9935..0af3d44a9 100644 --- a/src/nix/app.cc +++ b/src/nix/app.cc @@ -8,6 +8,7 @@ #include "command.hh" #include "derivations.hh" #include "downstream-placeholder.hh" +#include "overloaded.hh" namespace nix { diff --git a/src/nix/build.cc b/src/nix/build.cc index 479100186..7263c943b 100644 --- a/src/nix/build.cc +++ b/src/nix/build.cc @@ -4,6 +4,7 @@ #include "store-api.hh" #include "local-fs-store.hh" #include "progress-bar.hh" +#include "overloaded.hh" #include diff --git a/src/nix/log.cc b/src/nix/log.cc index 9a9bd30f9..6cdc8cb1b 100644 --- a/src/nix/log.cc +++ b/src/nix/log.cc @@ -4,6 +4,7 @@ #include "store-api.hh" #include "log-store.hh" #include "progress-bar.hh" +#include "overloaded.hh" using namespace nix; diff --git a/src/nix/profile.cc b/src/nix/profile.cc index 476ddcd60..59437e63e 100644 --- a/src/nix/profile.cc +++ b/src/nix/profile.cc @@ -10,6 +10,7 @@ #include "../nix-env/user-env.hh" #include "profiles.hh" #include "names.hh" +#include "overloaded.hh" #include #include diff --git a/tests/unit/libutil-support/tests/cli-literate-parser.cc b/tests/unit/libutil-support/tests/cli-literate-parser.cc index c943a813e..315e8f018 100644 --- a/tests/unit/libutil-support/tests/cli-literate-parser.cc +++ b/tests/unit/libutil-support/tests/cli-literate-parser.cc @@ -2,6 +2,7 @@ #include "libexpr/print.hh" #include "debug-char.hh" #include "types.hh" +#include "overloaded.hh" #include "util.hh" #include #include