From 48862f2477b181940ec27f4d3c09d7d125802161 Mon Sep 17 00:00:00 2001 From: Ali Mashtizadeh Date: Fri, 10 Oct 2014 10:54:37 -0700 Subject: [PATCH] Move to C++11 --- SConstruct | 20 +++------------ libori/index.cc | 3 +-- libori/localrepo.cc | 8 +++--- libori/metadatalog.cc | 4 +-- libori/packfile.cc | 4 +-- libori/peer.cc | 3 +-- libori/remoterepo.cc | 3 +-- libori/sshrepo.cc | 1 - libori/treediff.cc | 1 - libori/udsrepo.cc | 1 - liboriutil/kvserializer.cc | 40 +++++++++++++++--------------- liboriutil/lrucache.cc | 2 +- liboriutil/oriutil.cc | 10 ++++---- liboriutil/rwlock.cc | 2 +- liboriutil/rwlock_posix.cc | 2 +- liboriutil/rwlock_windows.cc | 2 +- orifs/oricmd.cc | 2 +- orifs/orifuse.cc | 2 +- orifs/oripriv.cc | 5 ++-- orifs/oripriv.h | 2 +- oris3/s3backup.h | 4 +-- public/ori/backup.h | 8 +++--- public/ori/httprepo.h | 4 +-- public/ori/index.h | 4 +-- public/ori/largeblob.h | 2 +- public/ori/localobject.h | 4 +-- public/ori/localrepo.h | 8 +++--- public/ori/metadatalog.h | 8 +++--- public/ori/object.h | 4 +-- public/ori/packfile.h | 12 ++++----- public/ori/peer.h | 8 +++--- public/ori/remoterepo.h | 10 ++++---- public/ori/sshrepo.h | 2 +- public/ori/tempdir.h | 8 +++--- public/ori/treediff.h | 4 +-- public/ori/udsrepo.h | 2 +- public/oriutil/dag.h | 48 ++++++++++++++++++------------------ public/oriutil/lrucache.h | 4 +-- public/oriutil/objecthash.h | 12 +++++++++ public/oriutil/objectinfo.h | 2 +- public/oriutil/oritr1.h | 24 ------------------ public/oriutil/rwlock.h | 2 +- 42 files changed, 134 insertions(+), 167 deletions(-) delete mode 100644 public/oriutil/oritr1.h diff --git a/SConstruct b/SConstruct index 38667e9..7f415cb 100644 --- a/SConstruct +++ b/SConstruct @@ -213,6 +213,7 @@ if not conf.CheckCC(): print 'Your C compiler and/or environment is incorrectly configured.' CheckFailed() +env.AppendUnique(CXXFLAGS = ['-std=c++11']) if not conf.CheckCXX(): print 'Your C++ compiler and/or environment is incorrectly configured.' CheckFailed() @@ -225,23 +226,8 @@ else: print 'pkg-config not found!' Exit(1) -# -#env.AppendUnique(CXXFLAGS = ['-std=c++11']) -#if not conf.CheckCXX(): -# env['CXXFLAGS'].remove('-std=c++11') -# -#env.AppendUnique(CXXFLAGS = ['-std=c++0x']) -#if not conf.CheckCXX(): -# env['CXXFLAGS'].remove('-std=c++0x') -# - -if conf.CheckCXXHeader('unordered_map'): - env.Append(CPPFLAGS = "-DHAVE_CXX11") -elif conf.CheckCXXHeader('tr1/unordered_map'): - env.Append(CPPFLAGS = "-DHAVE_CXXTR1") -else: - print 'Either C++11, C++0x, or C++ TR1 must be present!' - CheckFailed() +if not conf.CheckCXXHeader('unordered_map'): + print 'C++11 libraries appear to be missing' if not conf.CheckCXXHeader('boost/uuid/uuid.hpp'): print 'Boost UUID headers are missing!' diff --git a/libori/index.cc b/libori/index.cc index 162ecb3..c97e87f 100644 --- a/libori/index.cc +++ b/libori/index.cc @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -37,7 +37,6 @@ #include using namespace std; -using namespace std::tr1; /// Adds a checksum #define TOTAL_ENTRYSIZE (IndexEntry::SIZE + 16) diff --git a/libori/localrepo.cc b/libori/localrepo.cc index 28e4462..3dfec6c 100644 --- a/libori/localrepo.cc +++ b/libori/localrepo.cc @@ -995,7 +995,7 @@ struct MultiPullOp { // Pull queue deque toPull; - tr1::unordered_set toPullSet; + unordered_set toPullSet; // Remotes std::vector remotes; @@ -1171,7 +1171,7 @@ LocalRepo::multiPull(RemoteRepo::sp defaultRemote) void LocalRepo::transmit(bytewstream *bs, const ObjectHashVec &objs) { - std::tr1::unordered_set includedHashes; + unordered_set includedHashes; typedef std::vector IndexEntryVec; std::map packs; @@ -1998,8 +1998,8 @@ LocalRepo::graftSubtree(LocalRepo *r, cout << "Grafting " << (*it).hex() << endl; // Compute and set parents - tr1::unordered_set parents = gDag.getParents(*it); - tr1::unordered_set::iterator p; + unordered_set parents = gDag.getParents(*it); + unordered_set::iterator p; p = parents.begin(); if (parents.size() == 0) { diff --git a/libori/metadatalog.cc b/libori/metadatalog.cc index 9b9de9f..b50f611 100644 --- a/libori/metadatalog.cc +++ b/libori/metadatalog.cc @@ -25,8 +25,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/libori/packfile.cc b/libori/packfile.cc index e6c8022..8cebff4 100644 --- a/libori/packfile.cc +++ b/libori/packfile.cc @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include "tuneables.h" @@ -401,7 +401,7 @@ Packfile::transmit(bytewstream *bs, vector objects) } // Transmit object infos - tr1::unordered_set includedHashes; + unordered_set includedHashes; numobjs_t totalObjs = 0; strwstream infos_ss; diff --git a/libori/peer.cc b/libori/peer.cc index 30a9401..c256f4a 100644 --- a/libori/peer.cc +++ b/libori/peer.cc @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include @@ -34,7 +34,6 @@ #include using namespace std; -using namespace std::tr1; /******************************************************************** * diff --git a/libori/remoterepo.cc b/libori/remoterepo.cc index a33891d..c0f2c6d 100644 --- a/libori/remoterepo.cc +++ b/libori/remoterepo.cc @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -34,7 +34,6 @@ #include using namespace std; -using namespace std::tr1; RemoteRepo::RemoteRepo() : r(NULL) diff --git a/libori/sshrepo.cc b/libori/sshrepo.cc index 7011808..641398d 100644 --- a/libori/sshrepo.cc +++ b/libori/sshrepo.cc @@ -38,7 +38,6 @@ #include using namespace std; -using namespace std::tr1; /* * SshRepo diff --git a/libori/treediff.cc b/libori/treediff.cc index 1d4a63a..5fa5b87 100644 --- a/libori/treediff.cc +++ b/libori/treediff.cc @@ -33,7 +33,6 @@ #include using namespace std; -using namespace std::tr1; TreeDiffEntry::TreeDiffEntry() : type(Noop), diff --git a/libori/udsrepo.cc b/libori/udsrepo.cc index 84051c1..590f35a 100644 --- a/libori/udsrepo.cc +++ b/libori/udsrepo.cc @@ -34,7 +34,6 @@ #include using namespace std; -using namespace std::tr1; /* * UDSRepo diff --git a/liboriutil/kvserializer.cc b/liboriutil/kvserializer.cc index c587067..4aaa6fb 100644 --- a/liboriutil/kvserializer.cc +++ b/liboriutil/kvserializer.cc @@ -332,25 +332,25 @@ KVSerializer::getBlob() const blob = KVSERIALIZER_VERSIONSTR; - for (it = table.begin(); it != table.end(); it++) + for (auto &it : table) { string entry; uint8_t lenH, lenL; // length must be less than size - NOT_IMPLEMENTED(it->first.length() <= 0x0000FFFF); - lenH = it->first.length() >> 8; - lenL = it->first.length() & 0x00FF; + NOT_IMPLEMENTED(it.first.length() <= 0x0000FFFF); + lenH = it.first.length() >> 8; + lenL = it.first.length() & 0x00FF; entry = lenH; entry += lenL; - entry += it->first; + entry += it.first; - NOT_IMPLEMENTED(it->second.length() <= 0x0000FFFF); - lenH = it->second.length() >> 8; - lenL = it->second.length() & 0x00FF; + NOT_IMPLEMENTED(it.second.length() <= 0x0000FFFF); + lenH = it.second.length() >> 8; + lenL = it.second.length() & 0x00FF; entry += lenH; entry += lenL; - entry += it->second; + entry += it.second; blob += entry; } @@ -364,25 +364,25 @@ KVSerializer::dump() const map::const_iterator it; cout << "KVSerializer Dump:" << endl; - for (it = table.begin(); it != table.end(); it++) + for (auto &it : table) { - KVType type = getType(it->first); + KVType type = getType(it.first); char buf[32]; if (type == KVTypeString) { - cout << it->first << ": " << getStr(it->first) << endl; + cout << it.first << ": " << getStr(it.first) << endl; } else if (type == KVTypeU8) { - snprintf(buf, sizeof(buf), "%u", getU8(it->first)); - cout << it->first << ": " << buf << endl; + snprintf(buf, sizeof(buf), "%u", getU8(it.first)); + cout << it.first << ": " << buf << endl; } else if (type == KVTypeU16) { - snprintf(buf, sizeof(buf), "%u", getU16(it->first)); - cout << it->first << ": " << buf << endl; + snprintf(buf, sizeof(buf), "%u", getU16(it.first)); + cout << it.first << ": " << buf << endl; } else if (type == KVTypeU32) { - snprintf(buf, sizeof(buf), "%u", getU32(it->first)); - cout << it->first << ": " << buf << endl; + snprintf(buf, sizeof(buf), "%u", getU32(it.first)); + cout << it.first << ": " << buf << endl; } else if (type == KVTypeU64) { - snprintf(buf, sizeof(buf), "%llu", getU64(it->first)); - cout << it->first << ": " << buf << endl; + snprintf(buf, sizeof(buf), "%llu", getU64(it.first)); + cout << it.first << ": " << buf << endl; } else { cout << "Unknown type!" << endl; } diff --git a/liboriutil/lrucache.cc b/liboriutil/lrucache.cc index 2e24b63..e5d3afa 100644 --- a/liboriutil/lrucache.cc +++ b/liboriutil/lrucache.cc @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include diff --git a/liboriutil/oriutil.cc b/liboriutil/oriutil.cc index 4c55448..5ea93f3 100644 --- a/liboriutil/oriutil.cc +++ b/liboriutil/oriutil.cc @@ -68,15 +68,15 @@ Util_IsValidName(const string &path) if (path.size() == 0) return false; - for (it = path.begin(); it != path.end(); it++) + for (const char &it : path) { - if (*it >= 'a' && *it <= 'z') + if (it >= 'a' && it <= 'z') continue; - if (*it >= 'A' && *it <= 'Z') + if (it >= 'A' && it <= 'Z') continue; - if (*it >= '0' && *it <= '9') + if (it >= '0' && it <= '9') continue; - if (*it == '_' || *it == '.') + if (it == '_' || it == '.') continue; return false; } diff --git a/liboriutil/rwlock.cc b/liboriutil/rwlock.cc index 9c5330e..5b2b9f8 100644 --- a/liboriutil/rwlock.cc +++ b/liboriutil/rwlock.cc @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include diff --git a/liboriutil/rwlock_posix.cc b/liboriutil/rwlock_posix.cc index 883d4ba..a207f4d 100644 --- a/liboriutil/rwlock_posix.cc +++ b/liboriutil/rwlock_posix.cc @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/liboriutil/rwlock_windows.cc b/liboriutil/rwlock_windows.cc index c6a3b4f..68ef4cb 100644 --- a/liboriutil/rwlock_windows.cc +++ b/liboriutil/rwlock_windows.cc @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include diff --git a/orifs/oricmd.cc b/orifs/oricmd.cc index 825a5cd..633fbd2 100644 --- a/orifs/oricmd.cc +++ b/orifs/oricmd.cc @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include diff --git a/orifs/orifuse.cc b/orifs/orifuse.cc index 0b5df0d..2643ef3 100644 --- a/orifs/orifuse.cc +++ b/orifs/orifuse.cc @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include diff --git a/orifs/oripriv.cc b/orifs/oripriv.cc index 1df9c97..809b4bb 100644 --- a/orifs/oripriv.cc +++ b/orifs/oripriv.cc @@ -31,8 +31,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -51,7 +51,6 @@ #include "server.h" using namespace std; -using namespace std::tr1; // XXX: Hacky remove dependence extern mount_ori_config config; diff --git a/orifs/oripriv.h b/orifs/oripriv.h index bbb684b..c6c5f9d 100644 --- a/orifs/oripriv.h +++ b/orifs/oripriv.h @@ -205,7 +205,7 @@ private: uint64_t nextFH; std::map dirs; std::map paths; - std::tr1::unordered_map handles; + std::unordered_map handles; // Journal OriJournalMode::JournalMode journalMode; diff --git a/oris3/s3backup.h b/oris3/s3backup.h index fd37a17..93f6585 100644 --- a/oris3/s3backup.h +++ b/oris3/s3backup.h @@ -2,7 +2,7 @@ #define __S3BACKUP_H__ #include -#include +#include #include #include @@ -30,7 +30,7 @@ private: std::string bucketName; std::string _hostname; - std::tr1::shared_ptr ctx; + std::shared_ptr ctx; }; #endif /* __S3BACKUP_H__ */ diff --git a/public/ori/backup.h b/public/ori/backup.h index dbbfb19..8b5aeaa 100644 --- a/public/ori/backup.h +++ b/public/ori/backup.h @@ -18,8 +18,8 @@ #define __BACKUP_H__ #include -#include -#include +#include +#include #include "object.h" @@ -54,7 +54,7 @@ private: class BackupService { public: - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; // Is cached for the lifetime of a BackupService bool hasKey(const std::string &key) { @@ -91,7 +91,7 @@ public: } protected: - typedef std::tr1::unordered_map HasKeyCache; + typedef std::unordered_map HasKeyCache; HasKeyCache hasKeyCache; }; diff --git a/public/ori/httprepo.h b/public/ori/httprepo.h index 46e1bf2..d5e16af 100644 --- a/public/ori/httprepo.h +++ b/public/ori/httprepo.h @@ -19,7 +19,7 @@ #include #include -#include +#include #include "repo.h" @@ -56,7 +56,7 @@ private: std::map payloads; - std::tr1::unordered_set *containedObjs; + std::unordered_set *containedObjs; }; class HttpObject : public Object diff --git a/public/ori/index.h b/public/ori/index.h index 94dc172..ceac83e 100644 --- a/public/ori/index.h +++ b/public/ori/index.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include "object.h" #include "packfile.h" @@ -44,7 +44,7 @@ public: private: int fd; std::string fileName; - std::tr1::unordered_map index; + std::unordered_map index; void _writeEntry(const IndexEntry &e); }; diff --git a/public/ori/largeblob.h b/public/ori/largeblob.h index 89aea2c..62d4a02 100644 --- a/public/ori/largeblob.h +++ b/public/ori/largeblob.h @@ -39,7 +39,7 @@ class Repo; class LargeBlob { public: - LargeBlob(Repo *r); + explicit LargeBlob(Repo *r); ~LargeBlob(); void chunkFile(const std::string &path); void extractFile(const std::string &path); diff --git a/public/ori/localobject.h b/public/ori/localobject.h index edf85da..e836cb4 100644 --- a/public/ori/localobject.h +++ b/public/ori/localobject.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include "object.h" @@ -31,7 +31,7 @@ class LocalObject : public Object { public: - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; LocalObject(PfTransaction::sp transaction, size_t ix); LocalObject(Packfile::sp packfile, const IndexEntry &entry); diff --git a/public/ori/localrepo.h b/public/ori/localrepo.h index 5b0441f..073fef1 100644 --- a/public/ori/localrepo.h +++ b/public/ori/localrepo.h @@ -17,7 +17,7 @@ #ifndef __LOCALREPO_H__ #define __LOCALREPO_H__ -#include +#include #include #include @@ -70,15 +70,15 @@ class LocalRepoLock { std::string lockFile; public: - LocalRepoLock(const std::string &filename); + explicit LocalRepoLock(const std::string &filename); ~LocalRepoLock(); - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; }; class LocalRepo : public Repo { public: - LocalRepo(const std::string &root = ""); + explicit LocalRepo(const std::string &root = ""); ~LocalRepo(); void open(const std::string &root = ""); void close(); diff --git a/public/ori/metadatalog.h b/public/ori/metadatalog.h index c76565b..de4eae6 100644 --- a/public/ori/metadatalog.h +++ b/public/ori/metadatalog.h @@ -20,9 +20,9 @@ #include typedef int32_t refcount_t; -typedef std::tr1::unordered_map RefcountMap; -typedef std::tr1::unordered_map ObjMetadata; -typedef std::tr1::unordered_map MetadataMap; +typedef std::unordered_map RefcountMap; +typedef std::unordered_map ObjMetadata; +typedef std::unordered_map MetadataMap; class MetadataLog; class MdTransaction @@ -30,7 +30,7 @@ class MdTransaction public: MdTransaction(MetadataLog *log); ~MdTransaction(); - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; void addRef(const ObjectHash &hash); void decRef(const ObjectHash &hash); diff --git a/public/ori/object.h b/public/ori/object.h index 3771ab8..71a1b64 100644 --- a/public/ori/object.h +++ b/public/ori/object.h @@ -22,14 +22,14 @@ #include #include #include -#include +#include #include #include class Object { public: - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; Object() {} Object(const ObjectInfo &info) : info(info) {} diff --git a/public/ori/packfile.h b/public/ori/packfile.h index 2cade75..262ce1c 100644 --- a/public/ori/packfile.h +++ b/public/ori/packfile.h @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -47,7 +47,7 @@ class Index; class PfTransaction { public: - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; PfTransaction(Packfile *pf, Index *idx); ~PfTransaction(); @@ -62,7 +62,7 @@ public: size_t totalSize; bool committed; - std::tr1::unordered_map hashToIx; + std::unordered_map hashToIx; private: Packfile *pf; @@ -73,7 +73,7 @@ private: class Packfile { public: - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; Packfile(const std::string &filename, packid_t id); ~Packfile(); @@ -110,7 +110,7 @@ private: class PackfileManager { public: - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; PackfileManager(const std::string &rootPath); ~PackfileManager(); diff --git a/public/ori/peer.h b/public/ori/peer.h index cfcdb88..e25fcdd 100644 --- a/public/ori/peer.h +++ b/public/ori/peer.h @@ -22,7 +22,7 @@ #include #include -#include +#include class Repo; class HttpClient; @@ -57,9 +57,9 @@ private: std::string repoId; // Volatile State std::string peerFile; - std::tr1::shared_ptr cachedRepo; - std::tr1::shared_ptr hc; - std::tr1::shared_ptr sc; + std::shared_ptr cachedRepo; + std::shared_ptr hc; + std::shared_ptr sc; }; #endif /* __PEER_H__ */ diff --git a/public/ori/remoterepo.h b/public/ori/remoterepo.h index 8959d20..6e3e42d 100644 --- a/public/ori/remoterepo.h +++ b/public/ori/remoterepo.h @@ -18,7 +18,7 @@ #define __REMOTEREPO_H__ #include -#include +#include #include "repo.h" #include "httpclient.h" @@ -28,7 +28,7 @@ class RemoteRepo { public: - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; RemoteRepo(); ~RemoteRepo(); @@ -42,9 +42,9 @@ public: } private: Repo *r; - std::tr1::shared_ptr hc; - std::tr1::shared_ptr sc; - std::tr1::shared_ptr uc; + std::shared_ptr hc; + std::shared_ptr sc; + std::shared_ptr uc; std::string url; }; diff --git a/public/ori/sshrepo.h b/public/ori/sshrepo.h index b956d0b..1f986de 100644 --- a/public/ori/sshrepo.h +++ b/public/ori/sshrepo.h @@ -54,7 +54,7 @@ private: std::map payloads; - std::tr1::unordered_set *containedObjs; + std::unordered_set *containedObjs; }; class SshObject : public Object diff --git a/public/ori/tempdir.h b/public/ori/tempdir.h index 2a64178..59b5e24 100644 --- a/public/ori/tempdir.h +++ b/public/ori/tempdir.h @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include "repo.h" #include "commit.h" @@ -36,7 +36,7 @@ public: TempDir(const std::string &dirpath); ~TempDir(); - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; std::string pathTo(const std::string &file); /// Temp files are deleted along with the directory @@ -60,7 +60,7 @@ public: private: Index index; int objects_fd; - std::tr1::unordered_map offsets; + std::unordered_map offsets; }; class TempObject : public Object diff --git a/public/ori/treediff.h b/public/ori/treediff.h index a7940db..603cb31 100644 --- a/public/ori/treediff.h +++ b/public/ori/treediff.h @@ -19,7 +19,7 @@ #include #include -#include +#include #include "repo.h" #include "tree.h" @@ -81,7 +81,7 @@ public: std::vector entries; private: - std::tr1::unordered_map latestEntries; + std::unordered_map latestEntries; void _resetLatestEntry(const std::string &filepath); }; diff --git a/public/ori/udsrepo.h b/public/ori/udsrepo.h index 789f120..1647be9 100644 --- a/public/ori/udsrepo.h +++ b/public/ori/udsrepo.h @@ -63,7 +63,7 @@ private: std::map payloads; - std::tr1::unordered_set *containedObjs; + std::unordered_set *containedObjs; }; class UDSObject : public Object diff --git a/public/oriutil/dag.h b/public/oriutil/dag.h index cf05e6e..afa171f 100644 --- a/public/oriutil/dag.h +++ b/public/oriutil/dag.h @@ -25,7 +25,7 @@ #include #include #include -#include "oritr1.h" +#include #include "debug.h" @@ -50,17 +50,17 @@ public: { return v; } - std::tr1::unordered_set<_Key> listParents() + std::unordered_set<_Key> listParents() { return parents; } - std::tr1::unordered_set<_Key> listChildren() + std::unordered_set<_Key> listChildren() { return children; } void dump() { - typename std::tr1::unordered_set<_Key>::iterator it; + typename std::unordered_set<_Key>::iterator it; for (it = parents.begin(); it != parents.end(); it++) { std::cout << (*it).hex() << " <- " << k.hex() << std::endl; } @@ -70,8 +70,8 @@ private: friend class DAG <_Key, _Val>; _Key k; _Val v; - typename std::tr1::unordered_set<_Key> parents; - typename std::tr1::unordered_set<_Key> children; + typename std::unordered_set<_Key> parents; + typename std::unordered_set<_Key> children; }; template @@ -126,9 +126,9 @@ public: ASSERT(n != nodeMap.end()); - std::tr1::unordered_set<_Key> parents = (*n).listParents(); - std::tr1::unordered_set<_Key> children = (*n).listChildren(); - typename std::tr1::unordered_set<_Key>::iterator i; + std::unordered_set<_Key> parents = (*n).listParents(); + std::unordered_set<_Key> children = (*n).listChildren(); + typename std::unordered_set<_Key>::iterator i; // Break edges to parents for (i = parents.begin(); i != parents.end(); i++) @@ -156,8 +156,8 @@ public: ASSERT(n != nodeMap.end()); - std::tr1::unordered_set<_Key> children = (*n).listChildren(); - typename std::tr1::unordered_set<_Key>::iterator i; + std::unordered_set<_Key> children = (*n).listChildren(); + typename std::unordered_set<_Key>::iterator i; NOT_IMPLEMENTED(false); } @@ -177,7 +177,7 @@ public: /* * Get a node's parents */ - std::tr1::unordered_set<_Key> getParents(_Key k) + std::unordered_set<_Key> getParents(_Key k) { typename std::map<_Key, DAGNode<_Key, _Val> >::iterator it = nodeMap.find(k); @@ -220,10 +220,10 @@ public: { typename std::map<_Key, DAGNode<_Key, _Val> >::iterator it1; typename std::map<_Key, DAGNode<_Key, _Val> >::iterator it2; - typename std::tr1::unordered_set<_Key> p1p, p2p; - typename std::tr1::unordered_set<_Key> new_p1p, new_p2p; - typename std::tr1::unordered_set<_Key> next_p1p, next_p2p; - typename std::tr1::unordered_set<_Key>::iterator it; + typename std::unordered_set<_Key> p1p, p2p; + typename std::unordered_set<_Key> new_p1p, new_p2p; + typename std::unordered_set<_Key> next_p1p, next_p2p; + typename std::unordered_set<_Key>::iterator it; /* * Step 1: Add next set of nodes in p1 & p2 to unordered_set and paths to @@ -259,7 +259,7 @@ public: * nodes stored in p1p and p2p. */ for (it = new_p1p.begin(); it != new_p1p.end(); it++) { - typename std::tr1::unordered_set<_Key>::iterator k; + typename std::unordered_set<_Key>::iterator k; k = p2p.find(*it); if (k != p2p.end()) { return *k; @@ -269,7 +269,7 @@ public: p1p.insert(*it); } for (it = new_p2p.begin(); it != new_p2p.end(); it++) { - typename std::tr1::unordered_set<_Key>::iterator k; + typename std::unordered_set<_Key>::iterator k; k = p1p.find(*it); if (k != p1p.end()) { return *k; @@ -285,7 +285,7 @@ public: for (it = new_p1p.begin(); it != new_p1p.end(); it++) { it1 = nodeMap.find(*it); if (it1 != nodeMap.end()) { - typename std::tr1::unordered_set<_Key>::iterator k; + typename std::unordered_set<_Key>::iterator k; for (k = it1->second.parents.begin(); k != it1->second.parents.end(); k++) @@ -297,7 +297,7 @@ public: for (it = new_p2p.begin(); it != new_p2p.end(); it++) { it2 = nodeMap.find(*it); if (it2 != nodeMap.end()) { - typename std::tr1::unordered_set<_Key>::iterator k; + typename std::unordered_set<_Key>::iterator k; for (k = it2->second.parents.begin(); k != it2->second.parents.end(); k++) @@ -328,7 +328,7 @@ public: } // XXX: THIS DOES NOT PRODUCE THE RIGHT ORDERING std::list<_Key> getBottomUp(_Key tip) { - std::tr1::unordered_set<_Key> s = std::tr1::unordered_set<_Key>(); + std::unordered_set<_Key> s = std::unordered_set<_Key>(); std::list<_Key> v = std::list<_Key>(); std::list<_Key> q = std::list<_Key>(); std::list<_Key> nextQ = std::list<_Key>(); @@ -342,14 +342,14 @@ public: it != q.end(); it++) { - typename std::tr1::unordered_set<_Key>::iterator p; + typename std::unordered_set<_Key>::iterator p; p = s.find(*it); if (p == s.end()) { v.push_front(*it); s.insert(*it); - std::tr1::unordered_set<_Key> parents; - typename std::tr1::unordered_set<_Key>::iterator jt; + std::unordered_set<_Key> parents; + typename std::unordered_set<_Key>::iterator jt; parents = nodeMap[*it].listParents(); diff --git a/public/oriutil/lrucache.h b/public/oriutil/lrucache.h index 8ce379d..65b8cbb 100644 --- a/public/oriutil/lrucache.h +++ b/public/oriutil/lrucache.h @@ -22,7 +22,7 @@ #include #include #include -#include "oritr1.h" +#include #include "debug.h" #include "rwlock.h" @@ -32,7 +32,7 @@ class LRUCache { public: typedef std::list lru_list; - typedef std::tr1::unordered_map > lru_cache; LRUCache() : numItems(0) diff --git a/public/oriutil/objecthash.h b/public/oriutil/objecthash.h index 59c37a1..73f5a44 100644 --- a/public/oriutil/objecthash.h +++ b/public/oriutil/objecthash.h @@ -53,5 +53,17 @@ private: std::size_t hash_value(ObjectHash const& key); +namespace std +{ + template<> + struct hash + { + std::size_t operator()(ObjectHash const& key) const + { + return hash_value(key); + } + }; +} + #endif /* __OBJECTHASH_H__ */ diff --git a/public/oriutil/objectinfo.h b/public/oriutil/objectinfo.h index 4d8ea07..bd6dcb3 100644 --- a/public/oriutil/objectinfo.h +++ b/public/oriutil/objectinfo.h @@ -40,7 +40,7 @@ struct ObjectInfo { enum ZipAlgo { ZIPALGO_UNKNOWN, ZIPALGO_NONE, ZIPALGO_FASTLZ, ZIPALGO_LZMA }; ObjectInfo(); - ObjectInfo(const ObjectHash &hash); + explicit ObjectInfo(const ObjectHash &hash); std::string toString() const; void fromString(const std::string &info); diff --git a/public/oriutil/oritr1.h b/public/oriutil/oritr1.h deleted file mode 100644 index 9cbed73..0000000 --- a/public/oriutil/oritr1.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2013 Stanford University - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIM ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHORS BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef __ORITR1_H__ -#define __ORITR1_H__ - -#include -#include - -#endif /* __ORITR1_H__ */ - diff --git a/public/oriutil/rwlock.h b/public/oriutil/rwlock.h index b678c12..5e0b561 100644 --- a/public/oriutil/rwlock.h +++ b/public/oriutil/rwlock.h @@ -41,7 +41,7 @@ class RWLock; struct RWKey { - typedef std::tr1::shared_ptr sp; + typedef std::shared_ptr sp; virtual ~RWKey() { }; }; struct ReaderKey : public RWKey { -- 2.51.0