From dd95b67ce2ad5767155d3ccb56858f7ddf7b3810 Mon Sep 17 00:00:00 2001
From: Sam Yates <halfflat@gmail.com>
Date: Wed, 3 Aug 2016 15:03:30 +0200
Subject: [PATCH] Bugfix: build fail without TBB.

Plus: coding guidelines compliance.
---
 miniapp/io.cpp                    |  4 +--
 miniapp/trace_sampler.hpp         |  2 +-
 src/algorithms.hpp                |  6 ++--
 src/catypes.hpp                   |  2 +-
 src/catypes_io.cpp                |  2 +-
 src/cell.cpp                      |  2 +-
 src/fvm_cell.hpp                  |  2 +-
 src/mechanism_catalogue.hpp       |  9 ++++--
 src/model.hpp                     |  4 +--
 src/profiling/profiler.cpp        |  4 +--
 src/segment.hpp                   |  2 +-
 src/threading/serial.hpp          |  1 +
 src/util.hpp                      |  4 +--
 src/util/debug.hpp                |  2 +-
 src/util/lexcmp_def.hpp           |  2 +-
 src/util/optional.hpp             |  4 +--
 tests/unit/test_optional.cpp      | 50 +++++++++++++++++--------------
 tests/unit/test_parameters.cpp    |  2 +-
 tests/unit/test_uninitialized.cpp | 36 +++++++++++-----------
 19 files changed, 76 insertions(+), 64 deletions(-)

diff --git a/miniapp/io.cpp b/miniapp/io.cpp
index 722a754d..93a8d5e0 100644
--- a/miniapp/io.cpp
+++ b/miniapp/io.cpp
@@ -60,7 +60,7 @@ cl_options read_options(int argc, char** argv) {
         options.all_to_all = all_to_all_arg.getValue();
     }
     // catch any exceptions in command line handling
-    catch (TCLAP::ArgException &e) {
+    catch (TCLAP::ArgException& e) {
         throw usage_error("error parsing command line argument "+e.argId()+": "+e.error());
     }
 
@@ -79,7 +79,7 @@ cl_options read_options(int argc, char** argv) {
                 options.tfinal = fopts["tfinal"];
                 options.all_to_all = fopts["all_to_all"];
             }
-            catch(std::exception &e) {
+            catch (std::exception& e) {
                 throw model_description_error(
                     "unable to parse parameters in "+options.ifname+": "+e.what());
             }
diff --git a/miniapp/trace_sampler.hpp b/miniapp/trace_sampler.hpp
index 2e10257a..96ad269a 100644
--- a/miniapp/trace_sampler.hpp
+++ b/miniapp/trace_sampler.hpp
@@ -29,7 +29,7 @@ struct sample_trace {
     std::vector<sample_type> samples;
 
     sample_trace() =default;
-    sample_trace(cell_member_type probe_id, const std::string &name, const std::string &units):
+    sample_trace(cell_member_type probe_id, const std::string& name, const std::string& units):
         name(name), units(units), probe_id(probe_id)
     {}
 };
diff --git a/src/algorithms.hpp b/src/algorithms.hpp
index 60fd0863..65cbf4b6 100644
--- a/src/algorithms.hpp
+++ b/src/algorithms.hpp
@@ -121,7 +121,7 @@ bool is_positive(C const& c)
 }
 
 template<typename C>
-bool has_contiguous_segments(const C &parent_index)
+bool has_contiguous_segments(const C& parent_index)
 {
     static_assert(
         std::is_integral<typename C::value_type>::value,
@@ -151,7 +151,7 @@ bool has_contiguous_segments(const C &parent_index)
 }
 
 template<typename C>
-std::vector<typename C::value_type> child_count(const C &parent_index)
+std::vector<typename C::value_type> child_count(const C& parent_index)
 {
     static_assert(
         std::is_integral<typename C::value_type>::value,
@@ -229,7 +229,7 @@ typename C::value_type find_branch(const C& branch_index,
 
     auto it =  std::find_if(
         branch_index.begin(), branch_index.end(),
-        [nid](const value_type &v) { return v > nid; }
+        [nid](const value_type& v) { return v > nid; }
     );
 
     return it - branch_index.begin() - 1;
diff --git a/src/catypes.hpp b/src/catypes.hpp
index 0337c0ac..e2e9799b 100644
--- a/src/catypes.hpp
+++ b/src/catypes.hpp
@@ -35,4 +35,4 @@ DEFINE_LEXICOGRAPHIC_ORDERING(cell_member_type,(a.gid,a.index),(b.gid,b.index))
 } // namespace mc
 } // namespace nest
 
-std::ostream &operator<<(std::ostream& O, nest::mc::cell_member_type m);
+std::ostream& operator<<(std::ostream& O, nest::mc::cell_member_type m);
diff --git a/src/catypes_io.cpp b/src/catypes_io.cpp
index ea5ab59f..4c9d185f 100644
--- a/src/catypes_io.cpp
+++ b/src/catypes_io.cpp
@@ -2,7 +2,7 @@
 
 #include <catypes.hpp>
 
-std::ostream &operator<<(std::ostream& O, nest::mc::cell_member_type m) {
+std::ostream& operator<<(std::ostream& O, nest::mc::cell_member_type m) {
     return O << m.gid << ':' << m.index;
 }
 
diff --git a/src/cell.cpp b/src/cell.cpp
index cf4dd478..e96cae69 100644
--- a/src/cell.cpp
+++ b/src/cell.cpp
@@ -159,7 +159,7 @@ std::vector<cell::size_type> cell::compartment_counts() const
 cell::size_type cell::num_compartments() const
 {
     auto n = 0u;
-    for(auto &s : segments_) {
+    for(auto& s : segments_) {
         n += s->num_compartments();
     }
     return n;
diff --git a/src/fvm_cell.hpp b/src/fvm_cell.hpp
index 17176389..526fd22a 100644
--- a/src/fvm_cell.hpp
+++ b/src/fvm_cell.hpp
@@ -349,7 +349,7 @@ fvm_cell<T, I>::fvm_cell(nest::mc::cell const& cell)
         syn_map[syn.mechanism.name()].push_back(find_compartment_index(syn.location, graph));
     }
 
-    for (const auto &syni : syn_map) {
+    for (const auto& syni : syn_map) {
         const auto& mech_name = syni.first;
        // auto& helper = nest::mc::mechanisms::get_mechanism_helper(mech_name);
 
diff --git a/src/mechanism_catalogue.hpp b/src/mechanism_catalogue.hpp
index ef0b4ed8..c9d3e6de 100644
--- a/src/mechanism_catalogue.hpp
+++ b/src/mechanism_catalogue.hpp
@@ -19,7 +19,12 @@ struct catalogue {
     using view_type = typename mechanism<T, I>::view_type;
     using index_view = typename mechanism<T, I>::index_view;
 
-    static mechanism_ptr<T, I> make(const std::string &name, view_type vec_v, view_type vec_i, index_view node_indices)  {
+    static mechanism_ptr<T, I> make(
+        const std::string& name,
+        view_type vec_v,
+        view_type vec_i,
+        index_view node_indices)
+    {
         auto entry = mech_map.find(name);
         if (entry==mech_map.end()) {
             throw std::out_of_range("no such mechanism");
@@ -28,7 +33,7 @@ struct catalogue {
         return entry->second(vec_v, vec_i, node_indices);
     }
 
-    static bool has(const std::string &name) {
+    static bool has(const std::string& name) {
         return mech_map.count(name)>0;
     }
 
diff --git a/src/model.hpp b/src/model.hpp
index 556121ad..e819ff8b 100644
--- a/src/model.hpp
+++ b/src/model.hpp
@@ -29,7 +29,7 @@ public:
         probe_spec probe;
     };
 
-    model(const recipe &rec, cell_gid_type cell_from, cell_gid_type cell_to):
+    model(const recipe& rec, cell_gid_type cell_from, cell_gid_type cell_to):
         cell_from_(cell_from),
         cell_to_(cell_to),
         communicator_(cell_from, cell_to)
@@ -78,7 +78,7 @@ public:
             threading::parallel_for::apply(
                 0u, cell_groups_.size(),
                 [&](unsigned i) {
-                    auto &group = cell_groups_[i];
+                    auto& group = cell_groups_[i];
 
                     PE("stepping","events");
                     group.enqueue_events(communicator_.queue(i));
diff --git a/src/profiling/profiler.cpp b/src/profiling/profiler.cpp
index b5d2ad0d..1e30449a 100644
--- a/src/profiling/profiler.cpp
+++ b/src/profiling/profiler.cpp
@@ -66,7 +66,7 @@ void profiler_node::print_sub(
 
     if (print_children) {
         auto other = 0.;
-        for (auto &n : children) {
+        for (auto& n : children) {
             if (n.value<threshold || n.name=="other") {
                 other += n.value;
             }
@@ -162,7 +162,7 @@ double region_type::subregion_contributions() const {
 profiler_node region_type::populate_performance_tree() const {
     profiler_node tree(total(), name());
 
-    for (auto &it : subregions_) {
+    for (auto& it : subregions_) {
         tree.children.push_back(it.second->populate_performance_tree());
     }
 
diff --git a/src/segment.hpp b/src/segment.hpp
index b53d21be..a7600da9 100644
--- a/src/segment.hpp
+++ b/src/segment.hpp
@@ -208,7 +208,7 @@ public:
         mechanisms_.push_back(membrane_parameters());
     }
 
-    soma_segment(value_type r, point_type const &c)
+    soma_segment(value_type r, point_type const& c)
     :   soma_segment(r)
     {
         center_ = c;
diff --git a/src/threading/serial.hpp b/src/threading/serial.hpp
index 297f8266..8d9c4d64 100644
--- a/src/threading/serial.hpp
+++ b/src/threading/serial.hpp
@@ -7,6 +7,7 @@
 #include <array>
 #include <chrono>
 #include <string>
+#include <vector>
 
 namespace nest {
 namespace mc {
diff --git a/src/util.hpp b/src/util.hpp
index 29a6b28a..243987e6 100644
--- a/src/util.hpp
+++ b/src/util.hpp
@@ -18,7 +18,7 @@ using memory::util::cyan;
 
 template <typename T>
 std::ostream&
-operator << (std::ostream &o, std::vector<T>const& v)
+operator << (std::ostream& o, std::vector<T>const& v)
 {
     o << "[";
     for(auto const& i: v) {
@@ -29,7 +29,7 @@ operator << (std::ostream &o, std::vector<T>const& v)
 }
 
 template <typename T>
-std::ostream& print(std::ostream &o, std::vector<T>const& v)
+std::ostream& print(std::ostream& o, std::vector<T>const& v)
 {
     o << "[";
     for(auto const& i: v) {
diff --git a/src/util/debug.hpp b/src/util/debug.hpp
index 1d0ef633..f258b371 100644
--- a/src/util/debug.hpp
+++ b/src/util/debug.hpp
@@ -11,7 +11,7 @@ namespace mc {
 namespace util {
 
 bool failed_assertion(const char* assertion, const char* file, int line, const char* func);
-std::ostream &debug_emit_trace_leader(std::ostream& out, const char* file, int line, const char* varlist);
+std::ostream& debug_emit_trace_leader(std::ostream& out, const char* file, int line, const char* varlist);
 
 inline void debug_emit(std::ostream& out) {
     out << "\n";
diff --git a/src/util/lexcmp_def.hpp b/src/util/lexcmp_def.hpp
index d1c3e8a3..cfb297b1 100644
--- a/src/util/lexcmp_def.hpp
+++ b/src/util/lexcmp_def.hpp
@@ -20,7 +20,7 @@
 #include <tuple>
 
 #define DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(proxy,op,type,a_fields,b_fields) \
-inline bool operator op(const type &a,const type &b) { return proxy a_fields op proxy b_fields; }
+inline bool operator op(const type& a,const type& b) { return proxy a_fields op proxy b_fields; }
 
 #define DEFINE_LEXICOGRAPHIC_ORDERING(type,a_fields,b_fields) \
 DEFINE_LEXICOGRAPHIC_ORDERING_IMPL_(std::tie,<,type,a_fields,b_fields) \
diff --git a/src/util/optional.hpp b/src/util/optional.hpp
index 92191dff..6b4d0f8b 100644
--- a/src/util/optional.hpp
+++ b/src/util/optional.hpp
@@ -29,7 +29,7 @@ namespace util {
 template <typename X> struct optional;
 
 struct optional_unset_error: std::runtime_error {
-    explicit optional_unset_error(const std::string &what_str)
+    explicit optional_unset_error(const std::string& what_str)
         : std::runtime_error(what_str)
     {}
 
@@ -39,7 +39,7 @@ struct optional_unset_error: std::runtime_error {
 };
 
 struct optional_invalid_dereference: std::runtime_error {
-    explicit optional_invalid_dereference(const std::string &what_str)
+    explicit optional_invalid_dereference(const std::string& what_str)
         : std::runtime_error(what_str)
     {}
 
diff --git a/tests/unit/test_optional.cpp b/tests/unit/test_optional.cpp
index 35b74a47..4610f0c4 100644
--- a/tests/unit/test_optional.cpp
+++ b/tests/unit/test_optional.cpp
@@ -24,24 +24,30 @@ TEST(optionalm,unset_throw) {
     optional<int> a;
     int check=10;
 
-    try { a.get(); }
-    catch(optional_unset_error &e) {
+    try {
+        a.get();
+    }
+    catch (optional_unset_error& e) {
         ++check;
     }
     EXPECT_EQ(11,check);
 
     check=20;
     a=2;
-    try { a.get(); }
-    catch(optional_unset_error &e) {
+    try {
+        a.get();
+    }
+    catch (optional_unset_error& e) {
         ++check;
     }
     EXPECT_EQ(20,check);
 
     check=30;
     a.reset();
-    try { a.get(); }
-    catch(optional_unset_error &e) {
+    try {
+        a.get();
+    }
+    catch (optional_unset_error& e) {
         ++check;
     }
     EXPECT_EQ(31,check);
@@ -66,13 +72,13 @@ TEST(optionalm,ctor_conv) {
 
 TEST(optionalm,ctor_ref) {
     int v=10;
-    optional<int &> a(v);
+    optional<int&> a(v);
 
     EXPECT_EQ(10,a.get());
     v=20;
     EXPECT_EQ(20,a.get());
 
-    optional<int &> b(a),c=b,d=v;
+    optional<int&> b(a),c=b,d=v;
     EXPECT_EQ(&(a.get()),&(b.get()));
     EXPECT_EQ(&(a.get()),&(c.get()));
     EXPECT_EQ(&(a.get()),&(d.get()));
@@ -110,13 +116,13 @@ struct nomove {
 
     nomove(): value(0) {}
     nomove(int i): value(i) {}
-    nomove(const nomove &n): value(n.value) {}
-    nomove(nomove &&n) = delete;
+    nomove(const nomove& n): value(n.value) {}
+    nomove(nomove&& n) = delete;
 
-    nomove &operator=(const nomove &n) { value=n.value; return *this; }
+    nomove& operator=(const nomove& n) { value=n.value; return *this; }
 
-    bool operator==(const nomove &them) const { return them.value==value; }
-    bool operator!=(const nomove &them) const { return !(*this==them); }
+    bool operator==(const nomove& them) const { return them.value==value; }
+    bool operator!=(const nomove& them) const { return !(*this==them); }
 };
 
 TEST(optionalm,ctor_nomove) {
@@ -136,21 +142,21 @@ struct nocopy {
 
     nocopy(): value(0) {}
     nocopy(int i): value(i) {}
-    nocopy(const nocopy &n) = delete;
-    nocopy(nocopy &&n) {
+    nocopy(const nocopy& n) = delete;
+    nocopy(nocopy&& n) {
         value=n.value;
         n.value=0;
     }
 
-    nocopy &operator=(const nocopy &n) = delete;
-    nocopy &operator=(nocopy &&n) {
+    nocopy& operator=(const nocopy& n) = delete;
+    nocopy& operator=(nocopy&& n) {
         value=n.value;
         n.value=-1;
         return *this;
     }
 
-    bool operator==(const nocopy &them) const { return them.value==value; }
-    bool operator!=(const nocopy &them) const { return !(*this==them); }
+    bool operator==(const nocopy& them) const { return them.value==value; }
+    bool operator!=(const nocopy& them) const { return !(*this==them); }
 };
 
 TEST(optionalm,ctor_nocopy) {
@@ -251,13 +257,13 @@ TEST(optionalm,bind_to_optional_void) {
 
 TEST(optionalm,bind_with_ref) {
     optional<int> a=10;
-    a >> [](int &v) {++v; };
+    a >> [](int& v) { ++v; };
     EXPECT_EQ(11,*a);
 }
 
 struct check_cref {
-    int operator()(const int &) { return 10; }
-    int operator()(int &) { return 11; }
+    int operator()(const int&) { return 10; }
+    int operator()(int&) { return 11; }
 };
 
 TEST(optionalm,bind_constness) {
diff --git a/tests/unit/test_parameters.cpp b/tests/unit/test_parameters.cpp
index 07816404..a573e07c 100644
--- a/tests/unit/test_parameters.cpp
+++ b/tests/unit/test_parameters.cpp
@@ -28,7 +28,7 @@ TEST(parameters, setting)
     EXPECT_FALSE(list.add_parameter({"b", -3.0}));
     EXPECT_EQ(list.num_parameters(), 2);
 
-    auto &parms = list.parameters();
+    auto& parms = list.parameters();
     EXPECT_EQ(parms[0].name, "a");
     EXPECT_EQ(parms[0].value, 0.12);
     EXPECT_EQ(parms[0].range.min, 0);
diff --git a/tests/unit/test_uninitialized.cpp b/tests/unit/test_uninitialized.cpp
index dcc9e47c..1f04510d 100644
--- a/tests/unit/test_uninitialized.cpp
+++ b/tests/unit/test_uninitialized.cpp
@@ -7,16 +7,16 @@ using namespace nest::mc::util;
 namespace {
     struct count_ops {
         count_ops() {}
-        count_ops(const count_ops &n) { ++copy_ctor_count; }
-        count_ops(count_ops &&n) { ++move_ctor_count; }
+        count_ops(const count_ops& n) { ++copy_ctor_count; }
+        count_ops(count_ops&& n) { ++move_ctor_count; }
 
-        count_ops &operator=(const count_ops &n) { ++copy_assign_count; return *this; }
-        count_ops &operator=(count_ops &&n) { ++move_assign_count; return *this; }
+        count_ops& operator=(const count_ops& n) { ++copy_assign_count; return *this; }
+        count_ops& operator=(count_ops&& n) { ++move_assign_count; return *this; }
 
         static int copy_ctor_count,copy_assign_count;
         static int move_ctor_count,move_assign_count;
         static void reset_counts() {
-            copy_ctor_count=copy_assign_count=0; 
+            copy_ctor_count=copy_assign_count=0;
             move_ctor_count=move_assign_count=0;
         }
     };
@@ -53,11 +53,11 @@ TEST(uninitialized,ctor) {
 namespace {
     struct nocopy {
         nocopy() {}
-        nocopy(const nocopy &n) = delete;
-        nocopy(nocopy &&n) { ++move_ctor_count; }
+        nocopy(const nocopy& n) = delete;
+        nocopy(nocopy&& n) { ++move_ctor_count; }
 
-        nocopy &operator=(const nocopy &n) = delete;
-        nocopy &operator=(nocopy &&n) { ++move_assign_count; return *this; }
+        nocopy& operator=(const nocopy& n) = delete;
+        nocopy& operator=(nocopy&& n) { ++move_assign_count; return *this; }
 
         static int move_ctor_count,move_assign_count;
         static void reset_counts() { move_ctor_count=move_assign_count=0; }
@@ -85,11 +85,11 @@ TEST(uninitialized,ctor_nocopy) {
 namespace {
     struct nomove {
         nomove() {}
-        nomove(const nomove &n) { ++copy_ctor_count; }
-        nomove(nomove &&n) = delete;
+        nomove(const nomove& n) { ++copy_ctor_count; }
+        nomove(nomove&& n) = delete;
 
-        nomove &operator=(const nomove &n) { ++copy_assign_count; return *this; }
-        nomove &operator=(nomove &&n) = delete;
+        nomove& operator=(const nomove& n) { ++copy_assign_count; return *this; }
+        nomove& operator=(nomove&& n) = delete;
 
         static int copy_ctor_count,copy_assign_count;
         static void reset_counts() { copy_ctor_count=copy_assign_count=0; }
@@ -129,7 +129,7 @@ TEST(uninitialized,void) {
 }
 
 TEST(uninitialized,ref) {
-    uninitialized<int &> x,y;
+    uninitialized<int&> x,y;
     int a;
 
     x.construct(a);
@@ -151,8 +151,8 @@ namespace {
         mutable int op_count=0;
         mutable int const_op_count=0;
 
-        int operator()(const int &a) const { ++const_op_count; return a+1; }
-        int operator()(int &a) const { ++op_count; return ++a; }
+        int operator()(const int& a) const { ++const_op_count; return a+1; }
+        int operator()(int& a) const { ++op_count; return ++a; }
     };
 }
 
@@ -165,14 +165,14 @@ TEST(uninitialized,apply) {
     EXPECT_EQ(11,ua.cref());
     EXPECT_EQ(11,r);
 
-    uninitialized<int &> ub;
+    uninitialized<int&> ub;
     ub.construct(ua.ref());
 
     r=ub.apply(A);
     EXPECT_EQ(12,ua.cref());
     EXPECT_EQ(12,r);
 
-    uninitialized<const int &> uc;
+    uninitialized<const int&> uc;
     uc.construct(ua.ref());
 
     r=uc.apply(A);
-- 
GitLab