Skip to content

Commit

Permalink
Fix C++20 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
graham33 committed Oct 22, 2022
1 parent c5fd34a commit 4563e80
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/libstore/binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void BinaryCacheStore::queryPathInfoUncached(const StorePath & storePath,
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));

getFile(narInfoFile,
{[=](std::future<std::optional<std::string>> fut) {
{[=,this](std::future<std::optional<std::string>> fut) {
try {
auto data = fut.get();

Expand Down
2 changes: 1 addition & 1 deletion src/libstore/build/worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void Worker::run(const Goals & _topGoals)
if (!children.empty() || !waitingForAWhile.empty())
waitForInput();
else {
if (awake.empty() && 0 == settings.maxBuildJobs)
if (awake.empty() && 0U == settings.maxBuildJobs)
{
if (getMachines().empty())
throw Error("unable to start any build; either increase '--max-jobs' "
Expand Down
6 changes: 3 additions & 3 deletions src/libstore/globals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,19 @@ template<> void BaseSetting<SandboxMode>::convertToArg(Args & args, const std::s
.longName = name,
.description = "Enable sandboxing.",
.category = category,
.handler = {[=]() { override(smEnabled); }}
.handler = {[this]() { override(smEnabled); }}
});
args.addFlag({
.longName = "no-" + name,
.description = "Disable sandboxing.",
.category = category,
.handler = {[=]() { override(smDisabled); }}
.handler = {[this]() { override(smDisabled); }}
});
args.addFlag({
.longName = "relaxed-" + name,
.description = "Enable sandboxing, but allow builds to disable it.",
.category = category,
.handler = {[=]() { override(smRelaxed); }}
.handler = {[this]() { override(smRelaxed); }}
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/libutil/args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ MultiCommand::MultiCommand(const Commands & commands_)
expectArgs({
.label = "subcommand",
.optional = true,
.handler = {[=](std::string s) {
.handler = {[=,this](std::string s) {
assert(!command);
auto i = commands.find(s);
if (i == commands.end()) {
Expand Down
8 changes: 4 additions & 4 deletions src/libutil/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void BaseSetting<T>::convertToArg(Args & args, const std::string & category)
.description = fmt("Set the `%s` setting.", name),
.category = category,
.labels = {"value"},
.handler = {[=](std::string s) { overridden = true; set(s); }},
.handler = {[this](std::string s) { overridden = true; set(s); }},
});

if (isAppendable())
Expand All @@ -218,7 +218,7 @@ void BaseSetting<T>::convertToArg(Args & args, const std::string & category)
.description = fmt("Append to the `%s` setting.", name),
.category = category,
.labels = {"value"},
.handler = {[=](std::string s) { overridden = true; set(s, true); }},
.handler = {[this](std::string s) { overridden = true; set(s, true); }},
});
}

Expand Down Expand Up @@ -270,13 +270,13 @@ template<> void BaseSetting<bool>::convertToArg(Args & args, const std::string &
.longName = name,
.description = fmt("Enable the `%s` setting.", name),
.category = category,
.handler = {[=]() { override(true); }}
.handler = {[this]() { override(true); }}
});
args.addFlag({
.longName = "no-" + name,
.description = fmt("Disable the `%s` setting.", name),
.category = category,
.handler = {[=]() { override(false); }}
.handler = {[this]() { override(false); }}
});
}

Expand Down
12 changes: 8 additions & 4 deletions src/libutil/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,15 @@ public:
operator const T &() const { return value; }
operator T &() { return value; }
const T & get() const { return value; }
bool operator ==(const T & v2) const { return value == v2; }
bool operator !=(const T & v2) const { return value != v2; }
void operator =(const T & v) { assign(v); }
template<typename U>
bool operator ==(const U & v2) const { return value == v2; }
template<typename U>
bool operator !=(const U & v2) const { return value != v2; }
template<typename U>
void operator =(const U & v) { assign(v); }
virtual void assign(const T & v) { value = v; }
void setDefault(const T & v) { if (!overridden) value = v; }
template<typename U>
void setDefault(const U & v) { if (!overridden) value = v; }

void set(const std::string & str, bool append = false) override;

Expand Down

0 comments on commit 4563e80

Please sign in to comment.