Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace boost with std library functionality (part 1) #258

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Boundary/ConstantBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include "Boundary/ConstantBoundary.hh"
#include "Boundary/ConstantBoundaryUtilities.hh"

#include "boost/algorithm/string.hpp"

using std::vector;
using std::map;
using std::string;
Expand Down
5 changes: 2 additions & 3 deletions src/Boundary/InflowOutflowBoundary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
#include "Boundary/InflowOutflowBoundary.hh"
#include "Boundary/ConstantBoundaryUtilities.hh"

#include "boost/lexical_cast.hpp"
#include "boost/algorithm/string.hpp"
#include <string>

using std::vector;
using std::map;
Expand Down Expand Up @@ -516,7 +515,7 @@ InflowOutflowBoundary<Dimension>::clearStoredValues() {
template<typename Dimension>
std::string
InflowOutflowBoundary<Dimension>::label() const {
return "InflowOutflowBoundary" + boost::lexical_cast<std::string>(mBoundaryCount);
return "InflowOutflowBoundary" + std::to_string(mBoundaryCount);
}

//------------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions src/Boundary/ReflectingBoundary.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "Boundary/Boundary.hh"
#include "Boundary/PlanarBoundary.hh"
#include "RK/RKCorrectionParams.hh"
#include "boost/unordered_map.hpp"

#include "Eigen/Sparse"

Expand Down Expand Up @@ -99,7 +98,7 @@ public:
private:
//--------------------------- Private Interface ---------------------------//
Tensor mReflectOperator;
boost::unordered_map<RKOrder, std::pair<TransformationMatrix, TransformationMatrix>> mrkReflectOperators;
std::unordered_map<RKOrder, std::pair<TransformationMatrix, TransformationMatrix>> mrkReflectOperators;
};

}
Expand Down
2 changes: 0 additions & 2 deletions src/Damage/IvanoviSALEDamageModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
#include "Utilities/allReduce.hh"
#include "Utilities/uniform_random.hh"

#include <boost/functional/hash.hpp> // hash_combine

#include <string>
#include <vector>
#include <algorithm>
Expand Down
42 changes: 21 additions & 21 deletions src/DataBase/StateBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ namespace Spheral {
// //------------------------------------------------------------------------------
// template<typename T>
// T*
// extractType(boost::any& anyT) {
// extractType(std::any& anyT) {
// try {
// T* result = boost::any_cast<T*>(anyT);
// T* result = std::any_cast<T*>(anyT);
// return result;
// } catch (boost::any_cast_error) {
// } catch (std::any_cast_error) {
// return NULL;
// }
// }
Expand Down Expand Up @@ -125,21 +125,21 @@ operator==(const StateBase<Dimension>& rhs) const {
rhsItr != rhs.mStorage.end();
++rhsItr, ++lhsItr) {
try {
auto lhsPtr = boost::any_cast<FieldBase<Dimension>*>(lhsItr->second);
auto rhsPtr = boost::any_cast<FieldBase<Dimension>*>(rhsItr->second);
auto lhsPtr = std::any_cast<FieldBase<Dimension>*>(lhsItr->second);
auto rhsPtr = std::any_cast<FieldBase<Dimension>*>(rhsItr->second);
if (*lhsPtr != *rhsPtr) {
cerr << "Fields for " << lhsItr->first << " don't match." << endl;
result = false;
}
} catch (const boost::bad_any_cast&) {
} catch (const std::bad_any_cast&) {
try {
auto lhsPtr = boost::any_cast<vector<Vector>*>(lhsItr->second);
auto rhsPtr = boost::any_cast<vector<Vector>*>(rhsItr->second);
auto lhsPtr = std::any_cast<vector<Vector>*>(lhsItr->second);
auto rhsPtr = std::any_cast<vector<Vector>*>(rhsItr->second);
if (*lhsPtr != *rhsPtr) {
cerr << "vector<Vector> for " << lhsItr->first << " don't match." << endl;
result = false;
}
} catch (const boost::bad_any_cast&) {
} catch (const std::bad_any_cast&) {
std::cerr << "StateBase::operator== WARNING: unable to compare values for " << lhsItr->first << "\n";
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ void
StateBase<Dimension>::
enroll(FieldBase<Dimension>& field) {
const KeyType key = this->key(field);
boost::any fieldptr;
std::any fieldptr;
fieldptr = &field;
mStorage[key] = fieldptr;
mNodeListPtrs.insert(field.nodeListPtr());
Expand Down Expand Up @@ -382,15 +382,15 @@ assign(const StateBase<Dimension>& rhs) {
auto& anylhs = mStorage[itr->first];
const auto& anyrhs = itr->second;
try {
auto lhsptr = boost::any_cast<FieldBase<Dimension>*>(anylhs);
const auto rhsptr = boost::any_cast<FieldBase<Dimension>*>(anyrhs);
auto lhsptr = std::any_cast<FieldBase<Dimension>*>(anylhs);
const auto rhsptr = std::any_cast<FieldBase<Dimension>*>(anyrhs);
*lhsptr = *rhsptr;
} catch(const boost::bad_any_cast&) {
} catch(const std::bad_any_cast&) {
try {
auto lhsptr = boost::any_cast<vector<Vector>*>(anylhs);
const auto rhsptr = boost::any_cast<vector<Vector>*>(anyrhs);
auto lhsptr = std::any_cast<vector<Vector>*>(anylhs);
const auto rhsptr = std::any_cast<vector<Vector>*>(anyrhs);
*lhsptr = *rhsptr;
} catch(const boost::bad_any_cast&) {
} catch(const std::bad_any_cast&) {
// We'll assume other things don't need to be assigned...
// VERIFY2(false, "StateBase::assign ERROR: unknown type for key " << itr->first << "\n");
}
Expand Down Expand Up @@ -430,22 +430,22 @@ copyState() {
for (auto itr = mStorage.begin();
itr != mStorage.end();
++itr) {
boost::any anythingPtr = itr->second;
std::any anythingPtr = itr->second;

// Is this a Field?
try {
auto ptr = boost::any_cast<FieldBase<Dimension>*>(anythingPtr);
auto ptr = std::any_cast<FieldBase<Dimension>*>(anythingPtr);
mFieldCache.push_back(ptr->clone());
itr->second = mFieldCache.back().get();

} catch (const boost::bad_any_cast&) {
} catch (const std::bad_any_cast&) {
try {
auto ptr = boost::any_cast<vector<Vector>*>(anythingPtr);
auto ptr = std::any_cast<vector<Vector>*>(anythingPtr);
auto clone = std::shared_ptr<vector<Vector>>(new vector<Vector>(*ptr));
mCache.push_back(clone);
itr->second = clone.get();

} catch (const boost::bad_any_cast&) {
} catch (const std::bad_any_cast&) {
// We'll assume other things don't need to be copied...
// VERIFY2(false, "StateBase::copyState ERROR: unrecognized type for " << itr->first << "\n");
}
Expand Down
7 changes: 3 additions & 4 deletions src/DataBase/StateBase.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

#include "Field/FieldBase.hh"

#include "boost/any.hpp"

#include <any>
#include <string>
#include <utility>
#include <memory>
Expand Down Expand Up @@ -162,9 +161,9 @@ public:

protected:
//--------------------------- Protected Interface ---------------------------//
typedef std::map<KeyType, boost::any> StorageType;
typedef std::map<KeyType, std::any> StorageType;
typedef std::list<std::shared_ptr<FieldBase<Dimension>>> FieldCacheType;
typedef std::list<boost::any> CacheType;
typedef std::list<std::any> CacheType;

// Protected data.
StorageType mStorage;
Expand Down
6 changes: 3 additions & 3 deletions src/DataBase/StateBaseInline.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allFields(const Value&) const {
itr != mStorage.end();
++itr) {
try {
Field<Dimension, Value>* ptr = dynamic_cast<Field<Dimension, Value>*>(boost::any_cast<FieldBase<Dimension>*>(itr->second));
Field<Dimension, Value>* ptr = dynamic_cast<Field<Dimension, Value>*>(std::any_cast<FieldBase<Dimension>*>(itr->second));
if (ptr != 0) result.push_back(ptr);
} catch (...) {
// The field must have been the wrong type.
Expand Down Expand Up @@ -88,9 +88,9 @@ Value&
StateBase<Dimension>::
getAny(const typename StateBase<Dimension>::KeyType& key) const {
try {
Value& result = *boost::any_cast<Value*>(mStorage.find(key)->second);
Value& result = *std::any_cast<Value*>(mStorage.find(key)->second);
return result;
} catch (const boost::bad_any_cast&) {
} catch (const std::bad_any_cast&) {
VERIFY2(false, "StateBase::getAny ERROR: unable to extract Value for " << key << "\n");
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/DataBase/StateDerivatives.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,20 @@ Zero() {
++itr) {

try {
auto ptr = boost::any_cast<FieldBase<Dimension>*>(itr->second);
auto ptr = std::any_cast<FieldBase<Dimension>*>(itr->second);
ptr->Zero();

} catch (const boost::bad_any_cast&) {
} catch (const std::bad_any_cast&) {
try {
auto ptr = boost::any_cast<vector<Vector>*>(itr->second);
auto ptr = std::any_cast<vector<Vector>*>(itr->second);
ptr->clear();

} catch (const boost::bad_any_cast&) {
} catch (const std::bad_any_cast&) {
try {
auto ptr = boost::any_cast<vector<Scalar>*>(itr->second);
auto ptr = std::any_cast<vector<Scalar>*>(itr->second);
ptr->clear();

} catch (const boost::bad_any_cast&) {
} catch (const std::bad_any_cast&) {
VERIFY2(false, "StateDerivatives::Zero ERROR: unknown type for key " << itr->first << "\n");
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/Distributed/VoronoiRedistributeNodes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ using std::min;
using std::max;
using std::abs;

#include <boost/assign.hpp>

namespace Spheral {


Expand Down
1 change: 0 additions & 1 deletion src/FractalStruct/libs.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <array>
#include <utility>
#include <sys/stat.h>
#include <boost/random.hpp>
#include "fftw3-mpi.h"
#include "_hypre_utilities.h"
#include "HYPRE_krylov.h"
Expand Down
1 change: 0 additions & 1 deletion src/Geometry/RankNTensorInline.hh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <algorithm>
#include <limits.h>
#include <string>
#include "boost/static_assert.hpp"

#include "Utilities/SpheralFunctions.hh"
#include "Utilities/DBC.hh"
Expand Down
1 change: 0 additions & 1 deletion src/Geometry/invertRankNTensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <iostream>
#include <algorithm>
#include "boost/static_assert.hpp"
#include <assert.h>
#include "Eigen/Dense"

Expand Down
4 changes: 2 additions & 2 deletions src/Gravity/Tree.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <stdint.h>
#include "boost/unordered_map.hpp"
#include "boost/unordered_set.hpp"
#include <unordered_set>

namespace Spheral {

Expand Down Expand Up @@ -59,7 +59,7 @@ public:
// Data types we use to build the internal tree structure.
typedef uint32_t LevelKey;
typedef std::pair<size_t, size_t> NodeID;
typedef boost::unordered_map<NodeID, std::vector<boost::unordered_set<CellKey> > > CompletedCellSet;
typedef boost::unordered_map<NodeID, std::vector<std::unordered_set<CellKey> > > CompletedCellSet;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be std::unordered_map?

typedef boost::unordered_map<CellKey, Cell> TreeLevel;

static unsigned num1dbits; // The number of bits we quantize 1D coordinates to. We have to fit three of these in 64 bits.
Expand Down
2 changes: 1 addition & 1 deletion src/Gravity/TreeGravity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ evaluateDerivatives(const typename Dimension::Scalar /*time*/,
CompletedCellSet cellsCompleted;
for (unsigned nodeListi = 0; nodeListi != mass.numFields(); ++nodeListi) {
for (unsigned i = 0; i != mass[nodeListi]->numInternalElements(); ++i) {
cellsCompleted[NodeID(nodeListi, i)] = vector<boost::unordered_set<CellKey> >(num1dbits);
cellsCompleted[NodeID(nodeListi, i)] = vector<std::unordered_set<CellKey> >(num1dbits);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Gravity/TreeGravity.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include <stdint.h>
#include "boost/unordered_map.hpp"
#include "boost/unordered_set.hpp"
#include <unordered_set>

namespace Spheral {

Expand Down Expand Up @@ -132,7 +132,7 @@ private:
typedef uint32_t LevelKey;
typedef uint64_t CellKey;
typedef std::pair<size_t, size_t> NodeID;
typedef boost::unordered_map<NodeID, std::vector<boost::unordered_set<CellKey> > > CompletedCellSet;
typedef boost::unordered_map<NodeID, std::vector<std::unordered_set<CellKey> > > CompletedCellSet;

static unsigned num1dbits; // The number of bits we quantize 1D coordinates to. We have to fit three of these in 64 bits.
static CellKey max1dKey; // The maximum number of cells this corresponds to in a direction.
Expand Down
3 changes: 0 additions & 3 deletions src/KernelIntegrator/BilinearIndex.hh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <vector>
#include <unordered_map>
// #include <boost/functional/hash.hpp>
#include "DataBase/DataBase.hh"
#include "Field/FieldList.hh"

Expand All @@ -30,15 +29,13 @@ public:
// Typedefs for bilinear indexing
typedef typename std::pair<int, int> Pair;
typedef typename std::unordered_map<Pair, int, BilinearHash<Pair>> MapPair;
// typedef typename std::unordered_map<Pair, int, boost::hash<Pair>> MapPair;
typedef typename std::vector<Pair> VectorPair;
typedef FieldList<Dimension, MapPair> PairToFlat;
typedef FieldList<Dimension, VectorPair> FlatToPair;

// Typedefs for surface indexing
typedef typename std::array<int, Dimension::nDim> ArrayDim;
typedef typename std::unordered_map<ArrayDim, int, BilinearHash<ArrayDim>> MapNormal;
// typedef typename std::unordered_map<ArrayDim, int, boost::hash<ArrayDim>> MapNormal;
typedef typename std::vector<Vector> NormalType;
typedef FieldList<Dimension, MapNormal> NormalToFlat;
typedef FieldList<Dimension, NormalType> FlatToNormal;
Expand Down
4 changes: 0 additions & 4 deletions src/Mesh/MeshConstructionUtilities.hh
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ collapseDegenerateVertices(const std::vector<Vector>& vertices,
const Vector& xmax,
const Vector& boxInv,
const Uint tol) {
using namespace boost;
typedef std::tuple<Uint, Uint, Uint> Key;
using std::vector;
using std::set;
Expand Down Expand Up @@ -330,7 +329,6 @@ exchangeTuples(const std::vector<std::tuple<T, T, T> >& localKeys,
CONTRACT_VAR(neighborDomains);
CONTRACT_VAR(neighborKeys);
#ifdef USE_MPI
using namespace boost;
typedef std::tuple<T, T, T> Key;
using std::vector;

Expand Down Expand Up @@ -395,7 +393,6 @@ exchangeTuples(const std::vector<std::tuple<T, T, T> >& localKeys,
CONTRACT_VAR(sendIndices);
CONTRACT_VAR(neighborKeys);
#ifdef USE_MPI
using namespace boost;
typedef std::tuple<T, T, T> Key;

const unsigned numNeighborDomains = neighborDomains.size();
Expand Down Expand Up @@ -781,7 +778,6 @@ inline
std::tuple<T, T, T, T, T, T>
hashEdge(const std::tuple<T, T, T>& hashi,
const std::tuple<T, T, T>& hashj) {
using namespace boost;
return (hashi < hashj ?
std::make_tuple(std::get<0>(hashi), std::get<1>(hashi), std::get<2>(hashi),
std::get<0>(hashj), std::get<1>(hashj), std::get<2>(hashj)) :
Expand Down
3 changes: 0 additions & 3 deletions src/Neighbor/NodePairList.hh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <tuple>
#include <functional>
#include <iostream>
// #include <boost/container_hash/hash.hpp>

// These are based on what we get from size_t_bits
#define MAX_NODE_INDEX (size_t(1u) << ((SIZE_T_BITS - 10)/2))
Expand Down Expand Up @@ -103,8 +102,6 @@ namespace std {
struct hash<Spheral::NodePairIdxType> {
size_t operator()(const Spheral::NodePairIdxType& x) const {
return x.hash();
// boost::hash<std::tuple<int, int, int, int>> hasher;
// return hasher(std::make_tuple(x.i_node, x.i_list, x.j_node, x.j_list));
}
};
} // namespace std
Expand Down
2 changes: 1 addition & 1 deletion src/PYB11/Gravity/Tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Tree:
typedef uint64_t CellKey;
typedef uint32_t LevelKey;
typedef std::pair<size_t, size_t> NodeID;
typedef boost::unordered_map<NodeID, std::vector<boost::unordered_set<CellKey> > > CompletedCellSet;
typedef boost::unordered_map<NodeID, std::vector<std::unordered_set<CellKey> > > CompletedCellSet;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be std::unordered_map?

// typedef boost::unordered_map<CellKey, Tree::Cell> TreeLevel;
"""

Expand Down
1 change: 0 additions & 1 deletion src/SolidMaterial/ANEOS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "Utilities/bisectRoot.hh"
#include "Utilities/DBC.hh"

#include "boost/multi_array.hpp"
#include <iostream>
#include <ctime>
using std::vector;
Expand Down
Loading