diff --git a/modules/display/include/geometry_macros.h b/modules/display/include/geometry_macros.h index 6ccb84d9b8..060143b6c2 100644 --- a/modules/display/include/geometry_macros.h +++ b/modules/display/include/geometry_macros.h @@ -166,8 +166,8 @@ : display::PairGeometry(pp) {} \ display::Geometries get_components() const override { \ display::Geometries ret; \ - Decorator d0(get_particle_pair()[0]); \ - Decorator d1(get_particle_pair()[1]); \ + Decorator d0(std::get<0>(get_particle_pair())); \ + Decorator d1(std::get<1>(get_particle_pair())); \ action; \ return ret; \ } \ @@ -180,8 +180,8 @@ display::Geometries get_components() const override { \ display::Geometries ret; \ for(ParticleIndexPair pip : get_container()->get_contents()) { \ - Decorator d0(get_container()->get_model(), pip[0]); \ - Decorator d1(get_container()->get_model(), pip[1]); \ + Decorator d0(get_container()->get_model(), std::get<0>(pip)); \ + Decorator d1(get_container()->get_model(), std::get<1>(pip)); \ action; \ } \ return ret; \ diff --git a/modules/display/src/particle_geometry.cpp b/modules/display/src/particle_geometry.cpp index 37e95f16ec..1bae5068bc 100644 --- a/modules/display/src/particle_geometry.cpp +++ b/modules/display/src/particle_geometry.cpp @@ -20,7 +20,8 @@ SingletonsGeometry::SingletonsGeometry(SingletonContainerAdaptor pc, Color c) : Geometry(c, pc->get_name() + " geometry"), sc_(pc) {} PairGeometry::PairGeometry(const ParticlePair &p) - : Geometry(p.get_name() + " geometry"), p0_(p[0]), p1_(p[1]) {} + : Geometry(p.get_name() + " geometry"), + p0_(std::get<0>(p)), p1_(std::get<1>(p)) {} PairsGeometry::PairsGeometry(PairContainer *pc) : Geometry(pc->get_name() + " geometry"), sc_(pc) {} diff --git a/modules/kernel/include/cache.h b/modules/kernel/include/cache.h index fceeab35f3..736417fb02 100644 --- a/modules/kernel/include/cache.h +++ b/modules/kernel/include/cache.h @@ -96,8 +96,8 @@ class SparseSymmetricPairMemoizer { Generator gen_; Checker checker_; - static Key get_0(Entry e) { return e[0]; } - static Key get_1(Entry e) { return e[1]; } + static Key get_0(Entry e) { return std::get<0>(e); } + static Key get_1(Entry e) { return std::get<1>(e); } // The This:: is needed to make certain gcc versions (4.7) happier typedef boost::multi_index::global_fun P0Member; diff --git a/modules/kernel/src/internal/swig.cpp b/modules/kernel/src/internal/swig.cpp index eb6837113b..40239c199f 100644 --- a/modules/kernel/src/internal/swig.cpp +++ b/modules/kernel/src/internal/swig.cpp @@ -87,10 +87,8 @@ const Particles &_give_particles(Model *m) { const Particles &_pass_particles(const Particles &ps) { return ps; } Particle *_pass_particle(Particle *ps) { return ps; } const ParticlePair &_pass_particle_pair(const ParticlePair &pp) { - for (unsigned int i = 0; i < 2; ++i) { - std::cout << pp[i]->get_name() << " "; - } - std::cout << std::endl; + std::cout << std::get<0>(pp)->get_name() << " "; + std::cout << std::get<1>(pp)->get_name() << std::endl; return pp; } Particles _give_particles_copy(Model *m) { @@ -148,7 +146,8 @@ ParticleIndexes _create_particles_from_pdb(std::string name, Model *m) { Float _LogPairScore::evaluate_index(Model *m, const ParticleIndexPair &ipp, DerivativeAccumulator *) const { - ParticlePair pp(m->get_particle(ipp[0]), m->get_particle(ipp[1])); + ParticlePair pp(m->get_particle(std::get<0>(ipp)), + m->get_particle(std::get<1>(ipp))); if (map_.find(pp) == map_.end()) { map_[pp] = 0; } diff --git a/modules/kernel/test/test_pair_memoizer.cpp b/modules/kernel/test/test_pair_memoizer.cpp index bc9f0ebe1d..8f0c48d393 100644 --- a/modules/kernel/test/test_pair_memoizer.cpp +++ b/modules/kernel/test/test_pair_memoizer.cpp @@ -108,7 +108,7 @@ struct SortedPairs { } std::cout << "Returning "; for (unsigned int i = 0; i < ret.size(); ++i) { - std::cout << *ret[i][0] << "-" << *ret[i][1] << " "; + std::cout << *std::get<0>(ret[i]) << "-" << *std::get<1>(ret[i]) << " "; } std::cout << std::endl; return ret; @@ -118,16 +118,21 @@ struct SortedPairs { struct SetEquals { struct LessPair { bool operator()(IMP::Entry a, IMP::Entry b) const { - if (a[0] > a[1]) std::swap(a[0], a[1]); - if (b[0] > b[1]) std::swap(b[0], b[1]); - if (a[0] < b[0]) + if (std::get<0>(a) > std::get<1>(a)) { + std::swap(std::get<0>(a), std::get<1>(a)); + } + if (std::get<0>(b) > std::get<1>(b)) { + std::swap(std::get<0>(b), std::get<1>(b)); + } + if (std::get<0>(a) < std::get<0>(b)) { return true; - else if (a[0] > b[0]) + } else if (std::get<0>(a) > std::get<0>(b)) { return false; - else if (a[1] < b[1]) + } else if (std::get<1>(a) < std::get<1>(b)) { return true; - else + } else { return false; + } } }; bool operator()(SortedPairs::result_type t0) const { @@ -136,11 +141,11 @@ struct SetEquals { std::sort(t1.begin(), t1.end(), LessPair()); std::cout << "Comparing " << t0 << " and " << t1 << "= "; for (unsigned int i = 0; i < t0.size(); ++i) { - std::cout << *t0[i][0] << "-" << *t0[i][1] << " "; + std::cout << *std::get<0>(t0[i]) << "-" << *std::get<1>(t0[i]) << " "; } std::cout << " and "; for (unsigned int i = 0; i < t1.size(); ++i) { - std::cout << *t1[i][0] << "-" << *t1[i][1] << " "; + std::cout << *std::get<0>(t1[i]) << "-" << *std::get<1>(t1[i]) << " "; } std::cout << std::endl; if (t0.size() != t1.size()) return false; @@ -156,12 +161,12 @@ typedef IMP::SparseSymmetricPairMemoizer Table; struct Sum { int value; Sum() : value(0) {} - void operator()(IMP::Entry a) { value += *a[0] + *a[1]; } + void operator()(IMP::Entry a) { value += *std::get<0>(a) + *std::get<1>(a); } }; struct Show { void operator()(IMP::Entry a) { - std::cout << *a[0] << "-" << *a[1] << ", "; + std::cout << *std::get<0>(a) << "-" << *std::get<1>(a) << ", "; } }; diff --git a/modules/score_functor/include/SphereDistance.h b/modules/score_functor/include/SphereDistance.h index 05e5991637..245e2a423a 100644 --- a/modules/score_functor/include/SphereDistance.h +++ b/modules/score_functor/include/SphereDistance.h @@ -33,8 +33,8 @@ class SphereDistance : public BaseDistanceScore { typedef BaseDistanceScore P; static double get_rsum(Model *m, const ParticleIndexPair &pi) { - return m->get_sphere(pi[0]).get_radius() + - m->get_sphere(pi[1]).get_radius(); + return m->get_sphere(std::get<0>(pi)).get_radius() + + m->get_sphere(std::get<1>(pi)).get_radius(); } public: diff --git a/modules/score_functor/include/Statistical.h b/modules/score_functor/include/Statistical.h index 93e1450a64..964a89ee6d 100644 --- a/modules/score_functor/include/Statistical.h +++ b/modules/score_functor/include/Statistical.h @@ -90,8 +90,8 @@ class Statistical : public Score { if (distance >= threshold_ || distance < 0.001) { return 0; } - int pt = m->get_attribute(key_, pp[0]); - int lt = m->get_attribute(key_, pp[1]); + int pt = m->get_attribute(key_, std::get<0>(pp)); + int lt = m->get_attribute(key_, std::get<1>(pp)); if (pt == -1 || lt == -1) return 0; return table_->get_score(pt, lt, distance); } @@ -101,8 +101,8 @@ class Statistical : public Score { if (distance >= threshold_ || distance < 0.001) { return DerivativePair(0, 0); } - int pt = m->get_attribute(key_, pp[0]); - int lt = m->get_attribute(key_, pp[1]); + int pt = m->get_attribute(key_, std::get<0>(pp)); + int lt = m->get_attribute(key_, std::get<1>(pp)); if (pt == -1 || lt == -1) return DerivativePair(0, 0); return table_->get_score_with_derivative(pt, lt, distance); } diff --git a/modules/score_functor/include/internal/PMFTable.h b/modules/score_functor/include/internal/PMFTable.h index 7a6d1ac475..cc758dae8b 100644 --- a/modules/score_functor/include/internal/PMFTable.h +++ b/modules/score_functor/include/internal/PMFTable.h @@ -54,8 +54,8 @@ struct PMFTable : public Object { } const RawOpenCubicSpline &get(int i, int j) const { Array<2, int> is; - is[0] = i; - is[1] = j; + std::get<0>(is) = i; + std::get<1>(is) = j; typename Storage::ExtendedIndex ei(is.begin(), is.end()); return data_[data_.get_index(ei)]; } @@ -137,8 +137,8 @@ struct PMFTable : public Object { } order(i, j); Array<2, int> is; - is[0] = i; - is[1] = j; + std::get<0>(is) = i; + std::get<1>(is) = j; typename Storage::ExtendedIndex ei(is.begin(), is.end()); if (!data_.get_has_index(ei)) { data_.add_voxel(ei, score_functor::internal::RawOpenCubicSpline(