Merge pull request #6139 from edolstra/no-std-aliases

Remove std aliases
This commit is contained in:
Eelco Dolstra 2022-02-21 18:18:42 +01:00 committed by GitHub
commit 3848a8edb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 73 additions and 79 deletions

View file

@ -208,7 +208,7 @@ static int main_build_remote(int argc, char * * argv)
for (auto & m : machines)
error
% concatStringsSep<vector<string>>(", ", m.systemTypes)
% concatStringsSep<std::vector<string>>(", ", m.systemTypes)
% m.maxJobs
% concatStringsSep<StringSet>(", ", m.supportedFeatures)
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures);

View file

@ -266,7 +266,7 @@ void DrvInfo::setMeta(const string & name, Value * v)
/* Cache for already considered attrsets. */
typedef set<Bindings *> Done;
typedef std::set<Bindings *> Done;
/* Evaluate value `v'. If it evaluates to a set of type `derivation',

View file

@ -70,9 +70,9 @@ public:
#if HAVE_BOEHMGC
typedef list<DrvInfo, traceable_allocator<DrvInfo> > DrvInfos;
typedef std::list<DrvInfo, traceable_allocator<DrvInfo> > DrvInfos;
#else
typedef list<DrvInfo> DrvInfos;
typedef std::list<DrvInfo> DrvInfos;
#endif

View file

@ -335,8 +335,8 @@ struct ExprConcatStrings : Expr
{
Pos pos;
bool forceString;
vector<std::pair<Pos, Expr *> > * es;
ExprConcatStrings(const Pos & pos, bool forceString, vector<std::pair<Pos, Expr *> > * es)
std::vector<std::pair<Pos, Expr *> > * es;
ExprConcatStrings(const Pos & pos, bool forceString, std::vector<std::pair<Pos, Expr *> > * es)
: pos(pos), forceString(forceString), es(es) { };
COMMON_METHODS
};

View file

@ -193,7 +193,7 @@ static Formals * toFormals(ParseData & data, ParserFormals * formals,
static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols,
vector<std::pair<Pos, std::variant<Expr *, StringToken> > > & es)
std::vector<std::pair<Pos, std::variant<Expr *, StringToken> > > & es)
{
if (es.empty()) return new ExprString("");
@ -233,7 +233,7 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols,
}
/* Strip spaces from each line. */
vector<std::pair<Pos, Expr *> > * es2 = new vector<std::pair<Pos, Expr *> >;
std::vector<std::pair<Pos, Expr *> > * es2 = new std::vector<std::pair<Pos, Expr *> >;
atStartOfLine = true;
size_t curDropped = 0;
size_t n = es.size();
@ -415,7 +415,7 @@ expr_op
| expr_op UPDATE expr_op { $$ = new ExprOpUpdate(CUR_POS, $1, $3); }
| expr_op '?' attrpath { $$ = new ExprOpHasAttr($1, *$3); }
| expr_op '+' expr_op
{ $$ = new ExprConcatStrings(CUR_POS, false, new vector<std::pair<Pos, Expr *> >({{makeCurPos(@1, data), $1}, {makeCurPos(@3, data), $3}})); }
{ $$ = new ExprConcatStrings(CUR_POS, false, new std::vector<std::pair<Pos, Expr *> >({{makeCurPos(@1, data), $1}, {makeCurPos(@3, data), $3}})); }
| expr_op '-' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__sub")), {$1, $3}); }
| expr_op '*' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__mul")), {$1, $3}); }
| expr_op '/' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__div")), {$1, $3}); }
@ -503,9 +503,9 @@ string_parts_interpolated
: string_parts_interpolated STR
{ $$ = $1; $1->emplace_back(makeCurPos(@2, data), new ExprString(string($2))); }
| string_parts_interpolated DOLLAR_CURLY expr '}' { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $3); }
| DOLLAR_CURLY expr '}' { $$ = new vector<std::pair<Pos, Expr *> >; $$->emplace_back(makeCurPos(@1, data), $2); }
| DOLLAR_CURLY expr '}' { $$ = new std::vector<std::pair<Pos, Expr *> >; $$->emplace_back(makeCurPos(@1, data), $2); }
| STR DOLLAR_CURLY expr '}' {
$$ = new vector<std::pair<Pos, Expr *> >;
$$ = new std::vector<std::pair<Pos, Expr *> >;
$$->emplace_back(makeCurPos(@1, data), new ExprString(string($1)));
$$->emplace_back(makeCurPos(@2, data), $3);
}
@ -528,7 +528,7 @@ path_start
ind_string_parts
: ind_string_parts IND_STR { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $2); }
| ind_string_parts DOLLAR_CURLY expr '}' { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $3); }
| { $$ = new vector<std::pair<Pos, std::variant<Expr *, StringToken> > >; }
| { $$ = new std::vector<std::pair<Pos, std::variant<Expr *, StringToken> > >; }
;
binds
@ -582,9 +582,9 @@ attrpath
} else
$$->push_back(AttrName($3));
}
| attr { $$ = new vector<AttrName>; $$->push_back(AttrName(data->symbols.create($1))); }
| attr { $$ = new std::vector<AttrName>; $$->push_back(AttrName(data->symbols.create($1))); }
| string_attr
{ $$ = new vector<AttrName>;
{ $$ = new std::vector<AttrName>;
ExprString *str = dynamic_cast<ExprString *>($1);
if (str) {
$$->push_back(AttrName(data->symbols.create(str->s)));

View file

@ -574,9 +574,9 @@ struct CompareValues
#if HAVE_BOEHMGC
typedef list<Value *, gc_allocator<Value *> > ValueList;
typedef std::list<Value *, gc_allocator<Value *> > ValueList;
#else
typedef list<Value *> ValueList;
typedef std::list<Value *> ValueList;
#endif
@ -654,7 +654,7 @@ static void prim_genericClosure(EvalState & state, const Pos & pos, Value * * ar
// `doneKeys' doesn't need to be a GC root, because its values are
// reachable from res.
auto cmp = CompareValues(state);
set<Value *, decltype(cmp)> doneKeys(cmp);
std::set<Value *, decltype(cmp)> doneKeys(cmp);
while (!workSet.empty()) {
Value * e = *(workSet.begin());
workSet.pop_front();
@ -3649,12 +3649,12 @@ static void prim_replaceStrings(EvalState & state, const Pos & pos, Value * * ar
.errPos = pos
});
vector<string> from;
std::vector<string> from;
from.reserve(args[0]->listSize());
for (auto elem : args[0]->listItems())
from.emplace_back(state.forceString(*elem, pos));
vector<std::pair<string, PathSet>> to;
std::vector<std::pair<string, PathSet>> to;
to.reserve(args[1]->listSize());
for (auto elem : args[1]->listItems()) {
PathSet ctx;

View file

@ -17,8 +17,8 @@ namespace nix {
class Symbol
{
private:
const string * s; // pointer into SymbolTable
Symbol(const string * s) : s(s) { };
const std::string * s; // pointer into SymbolTable
Symbol(const std::string * s) : s(s) { };
friend class SymbolTable;
public:
@ -72,7 +72,7 @@ class SymbolTable
{
private:
std::unordered_map<std::string_view, Symbol> symbols;
std::list<string> store;
std::list<std::string> store;
public:
Symbol create(std::string_view s)
@ -84,7 +84,7 @@ public:
auto it = symbols.find(s);
if (it != symbols.end()) return it->second;
const string & rawSym = store.emplace_back(s);
auto & rawSym = store.emplace_back(s);
return symbols.emplace(rawSym, Symbol(&rawSym)).first->second;
}

View file

@ -77,20 +77,20 @@ class ExternalValueBase
public:
/* Return a simple string describing the type */
virtual string showType() const = 0;
virtual std::string showType() const = 0;
/* Return a string to be used in builtins.typeOf */
virtual string typeOf() const = 0;
virtual std::string typeOf() const = 0;
/* Coerce the value to a string. Defaults to uncoercable, i.e. throws an
* error
* error.
*/
virtual string coerceToString(const Pos & pos, PathSet & context, bool copyMore, bool copyToStore) const;
virtual std::string coerceToString(const Pos & pos, PathSet & context, bool copyMore, bool copyToStore) const;
/* Compare to another value of the same type. Defaults to uncomparable,
* i.e. always false.
*/
virtual bool operator==(const ExternalValueBase & b) const;
virtual bool operator ==(const ExternalValueBase & b) const;
/* Print the value as JSON. Defaults to unconvertable, i.e. throws an error */
virtual void printValueAsJSON(EvalState & state, bool strict,

View file

@ -1091,7 +1091,7 @@ HookReply DerivationGoal::tryBuildHook()
/* Create the log file and pipe. */
Path logFile = openLogFile();
set<int> fds;
std::set<int> fds;
fds.insert(hook->fromHook.readSide.get());
fds.insert(hook->builderOut.readSide.get());
worker.childStarted(shared_from_this(), fds, false, false);

View file

@ -18,8 +18,8 @@ struct CompareGoalPtrs {
};
/* Set of goals. */
typedef set<GoalPtr, CompareGoalPtrs> Goals;
typedef set<WeakGoalPtr, std::owner_less<WeakGoalPtr>> WeakGoals;
typedef std::set<GoalPtr, CompareGoalPtrs> Goals;
typedef std::set<WeakGoalPtr, std::owner_less<WeakGoalPtr>> WeakGoals;
/* A map of paths to goals (and the other way around). */
typedef std::map<StorePath, WeakGoalPtr> WeakGoalMap;

View file

@ -161,7 +161,7 @@ unsigned Worker::getNrLocalBuilds()
}
void Worker::childStarted(GoalPtr goal, const set<int> & fds,
void Worker::childStarted(GoalPtr goal, const std::set<int> & fds,
bool inBuildSlot, bool respectTimeouts)
{
Child child;
@ -377,7 +377,7 @@ void Worker::waitForInput()
GoalPtr goal = j->goal.lock();
assert(goal);
set<int> fds2(j->fds);
std::set<int> fds2(j->fds);
std::vector<unsigned char> buffer(4096);
for (auto & k : fds2) {
if (pollStatus.at(fdToPollStatus.at(k)).revents) {

View file

@ -38,7 +38,7 @@ struct Child
{
WeakGoalPtr goal;
Goal * goal2; // ugly hackery
set<int> fds;
std::set<int> fds;
bool respectTimeouts;
bool inBuildSlot;
steady_time_point lastOutput; /* time we last got output on stdout/stderr */
@ -167,7 +167,7 @@ public:
/* Registers a running child process. `inBuildSlot' means that
the process counts towards the jobs limit. */
void childStarted(GoalPtr goal, const set<int> & fds,
void childStarted(GoalPtr goal, const std::set<int> & fds,
bool inBuildSlot, bool respectTimeouts);
/* Unregisters a running child process. `wakeSleepers' should be

View file

@ -292,7 +292,7 @@ private:
typedef std::pair<dev_t, ino_t> Inode;
typedef set<Inode> InodesSeen;
typedef std::set<Inode> InodesSeen;
/* "Fix", or canonicalise, the meta-data of the files in a store path

View file

@ -8,19 +8,19 @@ class Store;
struct Machine {
const string storeUri;
const std::vector<string> systemTypes;
const string sshKey;
const std::string storeUri;
const std::vector<std::string> systemTypes;
const std::string sshKey;
const unsigned int maxJobs;
const unsigned int speedFactor;
const std::set<string> supportedFeatures;
const std::set<string> mandatoryFeatures;
const std::set<std::string> supportedFeatures;
const std::set<std::string> mandatoryFeatures;
const std::string sshPublicHostKey;
bool enabled = true;
bool allSupported(const std::set<string> & features) const;
bool allSupported(const std::set<std::string> & features) const;
bool mandatoryMet(const std::set<string> & features) const;
bool mandatoryMet(const std::set<std::string> & features) const;
Machine(decltype(storeUri) storeUri,
decltype(systemTypes) systemTypes,

View file

@ -10,9 +10,9 @@ struct Regex;
struct DrvName
{
string fullName;
string name;
string version;
std::string fullName;
std::string name;
std::string version;
unsigned int hits;
DrvName();
@ -25,7 +25,7 @@ private:
std::unique_ptr<Regex> regex;
};
typedef list<DrvName> DrvNames;
typedef std::list<DrvName> DrvNames;
std::string_view nextComponent(std::string_view::const_iterator & p,
const std::string_view::const_iterator end);

View file

@ -20,7 +20,7 @@ class PathLocks
{
private:
typedef std::pair<int, Path> FDPair;
list<FDPair> fds;
std::list<FDPair> fds;
bool deletePaths;
public:

View file

@ -90,7 +90,7 @@ void AbstractConfig::applyConfig(const std::string & contents, const std::string
if (hash != string::npos)
line = string(line, 0, hash);
vector<string> tokens = tokenizeString<vector<string> >(line);
auto tokens = tokenizeString<std::vector<string>>(line);
if (tokens.empty()) continue;
if (tokens.size() < 2)
@ -122,7 +122,7 @@ void AbstractConfig::applyConfig(const std::string & contents, const std::string
string name = tokens[0];
vector<string>::iterator i = tokens.begin();
auto i = tokens.begin();
advance(i, 2);
set(name, concatStringsSep(" ", Strings(i, tokens.end()))); // FIXME: slow

View file

@ -11,23 +11,17 @@
namespace nix {
using std::list;
using std::set;
using std::vector;
using std::string;
typedef list<string> Strings;
typedef set<string> StringSet;
typedef std::map<string, string> StringMap;
typedef std::list<std::string> Strings;
typedef std::set<std::string> StringSet;
typedef std::map<std::string, std::string> StringMap;
/* Paths are just strings. */
typedef string Path;
typedef std::string Path;
typedef std::string_view PathView;
typedef list<Path> Paths;
typedef set<Path> PathSet;
typedef std::list<Path> Paths;
typedef std::set<Path> PathSet;
typedef vector<std::pair<string, string>> Headers;
typedef std::vector<std::pair<std::string, std::string>> Headers;
/* Helper class to run code at startup. */
template<typename T>

View file

@ -1174,7 +1174,7 @@ void runProgram2(const RunOptions & options)
}
void closeMostFDs(const set<int> & exceptions)
void closeMostFDs(const std::set<int> & exceptions)
{
#if __linux__
try {
@ -1250,7 +1250,7 @@ template<class C> C tokenizeString(std::string_view s, std::string_view separato
template Strings tokenizeString(std::string_view s, std::string_view separators);
template StringSet tokenizeString(std::string_view s, std::string_view separators);
template vector<string> tokenizeString(std::string_view s, std::string_view separators);
template std::vector<string> tokenizeString(std::string_view s, std::string_view separators);
string chomp(std::string_view s)

View file

@ -99,7 +99,7 @@ struct DirEntry
: name(name), ino(ino), type(type) { }
};
typedef vector<DirEntry> DirEntries;
typedef std::vector<DirEntry> DirEntries;
DirEntries readDirectory(const Path & path);
@ -343,7 +343,7 @@ std::vector<char *> stringsToCharPtrs(const Strings & ss);
/* Close all file descriptors except those listed in the given set.
Good practice in child processes. */
void closeMostFDs(const set<int> & exceptions);
void closeMostFDs(const std::set<int> & exceptions);
/* Set the close-on-exec flag for the given file descriptor. */
void closeOnExec(int fd);

View file

@ -840,7 +840,7 @@ void printTable(Table & table)
{
auto nrColumns = table.size() > 0 ? table.front().size() : 0;
vector<size_t> widths;
std::vector<size_t> widths;
widths.resize(nrColumns);
for (auto & i : table) {
@ -907,7 +907,7 @@ static VersionDiff compareVersionAgainstSet(
}
static void queryJSON(Globals & globals, vector<DrvInfo> & elems, bool printOutPath, bool printMeta)
static void queryJSON(Globals & globals, std::vector<DrvInfo> & elems, bool printOutPath, bool printMeta)
{
JSONObject topObj(cout, true);
for (auto & i : elems) {
@ -1020,7 +1020,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
/* Sort them by name. */
/* !!! */
vector<DrvInfo> elems;
std::vector<DrvInfo> elems;
for (auto & i : elems_) elems.push_back(i);
sort(elems.begin(), elems.end(), cmpElemByName);

View file

@ -75,7 +75,7 @@ struct NixRepl
Expr * parseString(string s);
void evalString(string s, Value & v);
typedef set<Value *> ValuesSeen;
typedef std::set<Value *> ValuesSeen;
std::ostream & printValue(std::ostream & str, Value & v, unsigned int maxDepth);
std::ostream & printValue(std::ostream & str, Value & v, unsigned int maxDepth, ValuesSeen & seen);
};

View file

@ -23,9 +23,9 @@ Path resolveCacheFile(Path lib)
return cacheDir + "/" + lib;
}
std::set<string> readCacheFile(const Path & file)
std::set<std::string> readCacheFile(const Path & file)
{
return tokenizeString<set<string>>(readFile(file), "\n");
return tokenizeString<std::set<std::string>>(readFile(file), "\n");
}
std::set<std::string> runResolver(const Path & filename)
@ -81,7 +81,7 @@ std::set<std::string> runResolver(const Path & filename)
bool should_swap = magic == MH_CIGAM_64;
ptrdiff_t cmd_offset = mach64_offset + sizeof(mach_header_64);
std::set<string> libs;
std::set<std::string> libs;
for (uint32_t i = 0; i < DO_SWAP(should_swap, m_header->ncmds); i++) {
load_command * cmd = (load_command *) (obj + cmd_offset);
switch(DO_SWAP(should_swap, cmd->cmd)) {
@ -110,9 +110,9 @@ Path resolveSymlink(const Path & path)
: concatStrings(dirOf(path), "/", target);
}
std::set<string> resolveTree(const Path & path, PathSet & deps)
std::set<std::string> resolveTree(const Path & path, PathSet & deps)
{
std::set<string> results;
std::set<std::string> results;
if (!deps.insert(path).second) return {};
for (auto & lib : runResolver(path)) {
results.insert(lib);
@ -123,7 +123,7 @@ std::set<string> resolveTree(const Path & path, PathSet & deps)
return results;
}
std::set<string> getPath(const Path & path)
std::set<std::string> getPath(const Path & path)
{
if (hasPrefix(path, "/dev")) return {};
@ -131,7 +131,7 @@ std::set<string> getPath(const Path & path)
if (pathExists(cacheFile))
return readCacheFile(cacheFile);
std::set<string> deps, paths;
std::set<std::string> deps, paths;
paths.insert(path);
Path nextPath(path);
@ -180,7 +180,7 @@ int main(int argc, char ** argv)
impurePaths.insert("/usr/lib/libSystem.dylib");
}
std::set<string> allPaths;
std::set<std::string> allPaths;
for (auto & path : impurePaths)
for (auto & p : getPath(path))