diff --git a/miniapp/io.cpp b/miniapp/io.cpp index 722a754d7c6fb97952422aa77bee80c76ab36a62..93a8d5e0d35b45b23c78daa4fdba280cd02d0cf4 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 2e10257a12883e2dd9f8c69d2a2894cdbc001ea6..96ad269afed90551f710fe57c3651b58db3304fd 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 60fd0863e8770586764fb6129dee5f1699f57298..65cbf4b60c973a6b9ca987a0399a3803cddc8459 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 0337c0ac2831f1fde39b56f86d71fa7b6d36129c..e2e9799be3dbb7d4a91a75e01c8adf2eaa5a565e 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 ea5ab59fb6ac0a5cc134b613818797985c05593f..4c9d185f0bf68a2cd1c9ba8cbe67df26f614631d 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 cf4dd478367c318c6a3405eeb61f437fc0b68f46..e96cae69aca834d61d81c9c53c9488532a3b5b69 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 1717638931be43fde399db56ec1a7210e39616a3..526fd22a391b477d5af3c88a4535b4721c83cbfe 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 ef0b4ed8db8134456871bcb84eb9e134cfd26992..c9d3e6de2771a1b18fa05f104dd257b8c7fe6dd9 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 556121adfb42a4d32aed01c76537e9b78b9febc8..e819ff8b180beea18d5c0e745793bba1ef6aa8a5 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 b5d2ad0d8d7bd9efe7fd8e55e5f6720ab051b3f1..1e30449ab4b225385570292bea527fbcc6981c3d 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 b53d21be5b160cff9ab36d8886d8ea9422238dc6..a7600da948dfec79dfc600d9099b421accfd1aae 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 297f8266410ef334327856178346edb8a0d66607..8d9c4d64fd84805ed0909ad704ffc192bd0da748 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 29a6b28a9ec09cce13fcced0db20ae30aa3d803f..243987e628685ee4d4414394b054bebc6e7646a0 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 1d0ef63346068876f8366a0d423a8887fe4a7470..f258b37123755c7ec7a7324641249ed35290e8bb 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 d1c3e8a3bfc63341070b55b1320de03583797bbe..cfb297b1d16d3dbd7023bb7f300271eda0af1e41 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 92191dfff7adf9af084a2984b19210565da761e4..6b4d0f8b66cbdcf24c59914466a01621895ca2bb 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 35b74a470cea3e82a230592454126d04ce092da9..4610f0c48cf6b317f97e8a895f9bb09245ee7220 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 0781640489725a100b3e4ede3be40dfe168b1cef..a573e07cd9fce4581d2bd6b026e1499f94336d1d 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 dcc9e47ce6a7fa266376e054e8f84a04d8ec818d..1f04510d7df6af054eaec854d7e0c954ad5e73c8 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);