From 114a6e2b09eda7f23e7776e1cdf77715044e073e Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 11 Jan 2023 11:54:43 -0500 Subject: Make it hard to construct an empty `OutputsSpec::Names` This should be a non-empty set, and so we don't want people doing this by accident. We remove the zero-0 constructor with a little inheritance trickery. --- src/libstore/outputs-spec.hh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/libstore/outputs-spec.hh') diff --git a/src/libstore/outputs-spec.hh b/src/libstore/outputs-spec.hh index e81695da9..9c477ee2b 100644 --- a/src/libstore/outputs-spec.hh +++ b/src/libstore/outputs-spec.hh @@ -8,7 +8,22 @@ namespace nix { -typedef std::set OutputNames; +struct OutputNames : std::set { + using std::set::set; + + // These need to be "inherited manually" + OutputNames(const std::set & s) + : std::set(s) + { } + OutputNames(std::set && s) + : std::set(s) + { } + + /* This set should always be non-empty, so we delete this + constructor in order make creating empty ones by mistake harder. + */ + OutputNames() = delete; +}; struct AllOutputs { bool operator < (const AllOutputs & _) const { return false; } -- cgit v1.2.3