Merge pull request #7203 from graham33/feature/cpp20
Proposal: Use C++20
This commit is contained in:
commit
14b0b9ea5a
12 changed files with 24 additions and 20 deletions
2
Makefile
2
Makefile
|
@ -36,4 +36,4 @@ endif
|
||||||
|
|
||||||
include mk/lib.mk
|
include mk/lib.mk
|
||||||
|
|
||||||
GLOBAL_CXXFLAGS += -g -Wall -include config.h -std=c++17 -I src
|
GLOBAL_CXXFLAGS += -g -Wall -include config.h -std=c++20 -I src
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
makefiles = local.mk
|
makefiles = local.mk
|
||||||
|
|
||||||
GLOBAL_CXXFLAGS += -g -Wall -std=c++17 -I ../src
|
GLOBAL_CXXFLAGS += -g -Wall -std=c++20 -I ../src
|
||||||
|
|
||||||
-include Makefile.config
|
-include Makefile.config
|
||||||
|
|
||||||
|
|
|
@ -6,4 +6,4 @@ Name: Nix
|
||||||
Description: Nix Package Manager
|
Description: Nix Package Manager
|
||||||
Version: @PACKAGE_VERSION@
|
Version: @PACKAGE_VERSION@
|
||||||
Libs: -L${libdir} -lnixcmd
|
Libs: -L${libdir} -lnixcmd
|
||||||
Cflags: -I${includedir}/nix -std=c++17
|
Cflags: -I${includedir}/nix -std=c++20
|
||||||
|
|
|
@ -7,4 +7,4 @@ Description: Nix Package Manager
|
||||||
Version: @PACKAGE_VERSION@
|
Version: @PACKAGE_VERSION@
|
||||||
Requires: nix-store bdw-gc
|
Requires: nix-store bdw-gc
|
||||||
Libs: -L${libdir} -lnixexpr
|
Libs: -L${libdir} -lnixexpr
|
||||||
Cflags: -I${includedir}/nix -std=c++17
|
Cflags: -I${includedir}/nix -std=c++20
|
||||||
|
|
|
@ -6,4 +6,4 @@ Name: Nix
|
||||||
Description: Nix Package Manager
|
Description: Nix Package Manager
|
||||||
Version: @PACKAGE_VERSION@
|
Version: @PACKAGE_VERSION@
|
||||||
Libs: -L${libdir} -lnixmain
|
Libs: -L${libdir} -lnixmain
|
||||||
Cflags: -I${includedir}/nix -std=c++17
|
Cflags: -I${includedir}/nix -std=c++20
|
||||||
|
|
|
@ -370,7 +370,7 @@ void BinaryCacheStore::queryPathInfoUncached(const StorePath & storePath,
|
||||||
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
|
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
|
||||||
|
|
||||||
getFile(narInfoFile,
|
getFile(narInfoFile,
|
||||||
{[=](std::future<std::optional<std::string>> fut) {
|
{[=,this](std::future<std::optional<std::string>> fut) {
|
||||||
try {
|
try {
|
||||||
auto data = fut.get();
|
auto data = fut.get();
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ void Worker::run(const Goals & _topGoals)
|
||||||
if (!children.empty() || !waitingForAWhile.empty())
|
if (!children.empty() || !waitingForAWhile.empty())
|
||||||
waitForInput();
|
waitForInput();
|
||||||
else {
|
else {
|
||||||
if (awake.empty() && 0 == settings.maxBuildJobs)
|
if (awake.empty() && 0U == settings.maxBuildJobs)
|
||||||
{
|
{
|
||||||
if (getMachines().empty())
|
if (getMachines().empty())
|
||||||
throw Error("unable to start any build; either increase '--max-jobs' "
|
throw Error("unable to start any build; either increase '--max-jobs' "
|
||||||
|
|
|
@ -222,19 +222,19 @@ template<> void BaseSetting<SandboxMode>::convertToArg(Args & args, const std::s
|
||||||
.longName = name,
|
.longName = name,
|
||||||
.description = "Enable sandboxing.",
|
.description = "Enable sandboxing.",
|
||||||
.category = category,
|
.category = category,
|
||||||
.handler = {[=]() { override(smEnabled); }}
|
.handler = {[this]() { override(smEnabled); }}
|
||||||
});
|
});
|
||||||
args.addFlag({
|
args.addFlag({
|
||||||
.longName = "no-" + name,
|
.longName = "no-" + name,
|
||||||
.description = "Disable sandboxing.",
|
.description = "Disable sandboxing.",
|
||||||
.category = category,
|
.category = category,
|
||||||
.handler = {[=]() { override(smDisabled); }}
|
.handler = {[this]() { override(smDisabled); }}
|
||||||
});
|
});
|
||||||
args.addFlag({
|
args.addFlag({
|
||||||
.longName = "relaxed-" + name,
|
.longName = "relaxed-" + name,
|
||||||
.description = "Enable sandboxing, but allow builds to disable it.",
|
.description = "Enable sandboxing, but allow builds to disable it.",
|
||||||
.category = category,
|
.category = category,
|
||||||
.handler = {[=]() { override(smRelaxed); }}
|
.handler = {[this]() { override(smRelaxed); }}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,4 +6,4 @@ Name: Nix
|
||||||
Description: Nix Package Manager
|
Description: Nix Package Manager
|
||||||
Version: @PACKAGE_VERSION@
|
Version: @PACKAGE_VERSION@
|
||||||
Libs: -L${libdir} -lnixstore -lnixutil
|
Libs: -L${libdir} -lnixstore -lnixutil
|
||||||
Cflags: -I${includedir}/nix -std=c++17
|
Cflags: -I${includedir}/nix -std=c++20
|
||||||
|
|
|
@ -324,7 +324,7 @@ MultiCommand::MultiCommand(const Commands & commands_)
|
||||||
expectArgs({
|
expectArgs({
|
||||||
.label = "subcommand",
|
.label = "subcommand",
|
||||||
.optional = true,
|
.optional = true,
|
||||||
.handler = {[=](std::string s) {
|
.handler = {[=,this](std::string s) {
|
||||||
assert(!command);
|
assert(!command);
|
||||||
auto i = commands.find(s);
|
auto i = commands.find(s);
|
||||||
if (i == commands.end()) {
|
if (i == commands.end()) {
|
||||||
|
|
|
@ -209,7 +209,7 @@ void BaseSetting<T>::convertToArg(Args & args, const std::string & category)
|
||||||
.description = fmt("Set the `%s` setting.", name),
|
.description = fmt("Set the `%s` setting.", name),
|
||||||
.category = category,
|
.category = category,
|
||||||
.labels = {"value"},
|
.labels = {"value"},
|
||||||
.handler = {[=](std::string s) { overridden = true; set(s); }},
|
.handler = {[this](std::string s) { overridden = true; set(s); }},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isAppendable())
|
if (isAppendable())
|
||||||
|
@ -218,7 +218,7 @@ void BaseSetting<T>::convertToArg(Args & args, const std::string & category)
|
||||||
.description = fmt("Append to the `%s` setting.", name),
|
.description = fmt("Append to the `%s` setting.", name),
|
||||||
.category = category,
|
.category = category,
|
||||||
.labels = {"value"},
|
.labels = {"value"},
|
||||||
.handler = {[=](std::string s) { overridden = true; set(s, true); }},
|
.handler = {[this](std::string s) { overridden = true; set(s, true); }},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,13 +270,13 @@ template<> void BaseSetting<bool>::convertToArg(Args & args, const std::string &
|
||||||
.longName = name,
|
.longName = name,
|
||||||
.description = fmt("Enable the `%s` setting.", name),
|
.description = fmt("Enable the `%s` setting.", name),
|
||||||
.category = category,
|
.category = category,
|
||||||
.handler = {[=]() { override(true); }}
|
.handler = {[this]() { override(true); }}
|
||||||
});
|
});
|
||||||
args.addFlag({
|
args.addFlag({
|
||||||
.longName = "no-" + name,
|
.longName = "no-" + name,
|
||||||
.description = fmt("Disable the `%s` setting.", name),
|
.description = fmt("Disable the `%s` setting.", name),
|
||||||
.category = category,
|
.category = category,
|
||||||
.handler = {[=]() { override(false); }}
|
.handler = {[this]() { override(false); }}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,11 +250,15 @@ public:
|
||||||
operator const T &() const { return value; }
|
operator const T &() const { return value; }
|
||||||
operator T &() { return value; }
|
operator T &() { return value; }
|
||||||
const T & get() const { return value; }
|
const T & get() const { return value; }
|
||||||
bool operator ==(const T & v2) const { return value == v2; }
|
template<typename U>
|
||||||
bool operator !=(const T & v2) const { return value != v2; }
|
bool operator ==(const U & 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>
|
||||||
|
void operator =(const U & v) { assign(v); }
|
||||||
virtual void assign(const T & v) { value = 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;
|
void set(const std::string & str, bool append = false) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue