libutil: move overloaded into own header

util.hh is huge and an upcoming new header wants just overloaded, not
the entire rest. also step towards reducing compile times.

Change-Id: I5ebe8c4692b4e41bc794b8f2d6d138073134dd9e
This commit is contained in:
eldritch horrors 2024-03-19 20:38:27 +01:00
parent e94033c4af
commit a81ec42ecf
39 changed files with 54 additions and 7 deletions

View file

@ -1,6 +1,7 @@
#include "built-path.hh" #include "built-path.hh"
#include "derivations.hh" #include "derivations.hh"
#include "store-api.hh" #include "store-api.hh"
#include "overloaded.hh"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>

View file

@ -5,6 +5,7 @@
#include "nixexpr.hh" #include "nixexpr.hh"
#include "profiles.hh" #include "profiles.hh"
#include "repl.hh" #include "repl.hh"
#include "overloaded.hh"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>

View file

@ -16,6 +16,7 @@
#include "url.hh" #include "url.hh"
#include "registry.hh" #include "registry.hh"
#include "build-result.hh" #include "build-result.hh"
#include "overloaded.hh"
#include <regex> #include <regex>
#include <queue> #include <queue>

View file

@ -1,5 +1,6 @@
#include "installable-derived-path.hh" #include "installable-derived-path.hh"
#include "derivations.hh" #include "derivations.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -17,6 +17,7 @@
#include "url.hh" #include "url.hh"
#include "registry.hh" #include "registry.hh"
#include "build-result.hh" #include "build-result.hh"
#include "overloaded.hh"
#include <regex> #include <regex>
#include <queue> #include <queue>

View file

@ -20,6 +20,7 @@
#include "url.hh" #include "url.hh"
#include "registry.hh" #include "registry.hh"
#include "build-result.hh" #include "build-result.hh"
#include "overloaded.hh"
#include <regex> #include <regex>
#include <queue> #include <queue>

View file

@ -3,6 +3,7 @@
#include "eval.hh" #include "eval.hh"
#include "eval-inline.hh" #include "eval-inline.hh"
#include "store-api.hh" #include "store-api.hh"
#include "overloaded.hh"
namespace nix::eval_cache { namespace nix::eval_cache {

View file

@ -19,6 +19,7 @@
#include "fetch-to-store.hh" #include "fetch-to-store.hh"
#include "flake/flakeref.hh" #include "flake/flakeref.hh"
#include "parser-tab.hh" #include "parser-tab.hh"
#include "overloaded.hh"
#include <algorithm> #include <algorithm>
#include <chrono> #include <chrono>

View file

@ -8,6 +8,7 @@
#include "fetchers.hh" #include "fetchers.hh"
#include "finally.hh" #include "finally.hh"
#include "fetch-settings.hh" #include "fetch-settings.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -2,6 +2,7 @@
///@file ///@file
#include "eval.hh" #include "eval.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -15,6 +15,7 @@
#include "value-to-xml.hh" #include "value-to-xml.hh"
#include "primops.hh" #include "primops.hh"
#include "fetch-to-store.hh" #include "fetch-to-store.hh"
#include "overloaded.hh"
#include <boost/container/small_vector.hpp> #include <boost/container/small_vector.hpp>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>

View file

@ -2,6 +2,7 @@
#include "eval-inline.hh" #include "eval-inline.hh"
#include "derivations.hh" #include "derivations.hh"
#include "store-api.hh" #include "store-api.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -1,4 +1,5 @@
#include "value/context.hh" #include "value/context.hh"
#include "overloaded.hh"
#include <optional> #include <optional>

View file

@ -13,6 +13,7 @@
#include "topo-sort.hh" #include "topo-sort.hh"
#include "callback.hh" #include "callback.hh"
#include "local-store.hh" // TODO remove, along with remaining downcasts #include "local-store.hh" // TODO remove, along with remaining downcasts
#include "overloaded.hh"
#include <regex> #include <regex>
#include <queue> #include <queue>

View file

@ -16,6 +16,7 @@
#include "cgroup.hh" #include "cgroup.hh"
#include "personality.hh" #include "personality.hh"
#include "namespaces.hh" #include "namespaces.hh"
#include "overloaded.hh"
#include <regex> #include <regex>
#include <queue> #include <queue>

View file

@ -5,6 +5,7 @@
#include "local-derivation-goal.hh" #include "local-derivation-goal.hh"
#include "signals.hh" #include "signals.hh"
#include "hook-instance.hh" #include "hook-instance.hh"
#include "overloaded.hh"
#include <poll.h> #include <poll.h>

View file

@ -1,6 +1,7 @@
#include "args.hh" #include "args.hh"
#include "content-address.hh" #include "content-address.hh"
#include "split.hh" #include "split.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -13,6 +13,7 @@
#include "archive.hh" #include "archive.hh"
#include "derivations.hh" #include "derivations.hh"
#include "args.hh" #include "args.hh"
#include "overloaded.hh"
namespace nix::daemon { namespace nix::daemon {

View file

@ -8,6 +8,7 @@
#include "common-protocol.hh" #include "common-protocol.hh"
#include "common-protocol-impl.hh" #include "common-protocol-impl.hh"
#include "fs-accessor.hh" #include "fs-accessor.hh"
#include "overloaded.hh"
#include <boost/container/small_vector.hpp> #include <boost/container/small_vector.hpp>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>

View file

@ -1,4 +1,5 @@
#include "derived-path-map.hh" #include "derived-path-map.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -1,5 +1,6 @@
#include "derived-path.hh" #include "derived-path.hh"
#include "store-api.hh" #include "store-api.hh"
#include "overloaded.hh"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>

View file

@ -1,5 +1,6 @@
#include "downstream-placeholder.hh" #include "downstream-placeholder.hh"
#include "derivations.hh" #include "derivations.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -10,6 +10,7 @@
#include "ssh.hh" #include "ssh.hh"
#include "derivations.hh" #include "derivations.hh"
#include "callback.hh" #include "callback.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -11,6 +11,7 @@
#include "signals.hh" #include "signals.hh"
#include "finally.hh" #include "finally.hh"
#include "compression.hh" #include "compression.hh"
#include "overloaded.hh"
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>

View file

@ -8,6 +8,7 @@
#include "callback.hh" #include "callback.hh"
#include "closure.hh" #include "closure.hh"
#include "filetransfer.hh" #include "filetransfer.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -5,6 +5,7 @@
#include "regex-combinators.hh" #include "regex-combinators.hh"
#include "outputs-spec.hh" #include "outputs-spec.hh"
#include "path-regex.hh" #include "path-regex.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -1,5 +1,6 @@
#include "path-info.hh" #include "path-info.hh"
#include "store-api.hh" #include "store-api.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -1,5 +1,6 @@
#include "path-with-outputs.hh" #include "path-with-outputs.hh"
#include "store-api.hh" #include "store-api.hh"
#include "overloaded.hh"
#include <regex> #include <regex>

View file

@ -17,6 +17,7 @@
#include "logging.hh" #include "logging.hh"
#include "callback.hh" #include "callback.hh"
#include "filetransfer.hh" #include "filetransfer.hh"
#include "overloaded.hh"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
namespace nix { namespace nix {

View file

@ -15,6 +15,7 @@
// FIXME this should not be here, see TODO below on // FIXME this should not be here, see TODO below on
// `addMultipleToStore`. // `addMultipleToStore`.
#include "worker-protocol.hh" #include "worker-protocol.hh"
#include "overloaded.hh"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <regex> #include <regex>

View file

@ -7,6 +7,7 @@
#include "worker-protocol-impl.hh" #include "worker-protocol-impl.hh"
#include "archive.hh" #include "archive.hh"
#include "path-info.hh" #include "path-info.hh"
#include "overloaded.hh"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>

17
src/libutil/overloaded.hh Normal file
View file

@ -0,0 +1,17 @@
#pragma once
namespace nix {
/**
* C++17 std::visit boilerplate
*/
template<class... Ts>
struct overloaded : Ts...
{
using Ts::operator()...;
};
template<class... Ts>
overloaded(Ts...) -> overloaded<Ts...>;
}

View file

@ -1,4 +1,5 @@
#include "position.hh" #include "position.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -880,13 +880,6 @@ constexpr auto enumerate(T && iterable)
} }
/**
* C++17 std::visit boilerplate
*/
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
std::string showBytes(uint64_t bytes); std::string showBytes(uint64_t bytes);

View file

@ -8,6 +8,7 @@
#include "command.hh" #include "command.hh"
#include "derivations.hh" #include "derivations.hh"
#include "downstream-placeholder.hh" #include "downstream-placeholder.hh"
#include "overloaded.hh"
namespace nix { namespace nix {

View file

@ -4,6 +4,7 @@
#include "store-api.hh" #include "store-api.hh"
#include "local-fs-store.hh" #include "local-fs-store.hh"
#include "progress-bar.hh" #include "progress-bar.hh"
#include "overloaded.hh"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>

View file

@ -4,6 +4,7 @@
#include "store-api.hh" #include "store-api.hh"
#include "log-store.hh" #include "log-store.hh"
#include "progress-bar.hh" #include "progress-bar.hh"
#include "overloaded.hh"
using namespace nix; using namespace nix;

View file

@ -10,6 +10,7 @@
#include "../nix-env/user-env.hh" #include "../nix-env/user-env.hh"
#include "profiles.hh" #include "profiles.hh"
#include "names.hh" #include "names.hh"
#include "overloaded.hh"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <regex> #include <regex>

View file

@ -2,6 +2,7 @@
#include "libexpr/print.hh" #include "libexpr/print.hh"
#include "debug-char.hh" #include "debug-char.hh"
#include "types.hh" #include "types.hh"
#include "overloaded.hh"
#include "util.hh" #include "util.hh"
#include <iostream> #include <iostream>
#include <memory> #include <memory>