diff --git a/external/modparser b/external/modparser index 588ca1a5ea28ef04d17b318e754d479e5489eb9a..b200bf6376a2dc30edea98fcc2375fc9be095135 160000 --- a/external/modparser +++ b/external/modparser @@ -1 +1 @@ -Subproject commit 588ca1a5ea28ef04d17b318e754d479e5489eb9a +Subproject commit b200bf6376a2dc30edea98fcc2375fc9be095135 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..7789b24156d403ba702404ccf67a67d0b2cfcedf 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, @@ -141,7 +141,7 @@ bool has_contiguous_segments(const C &parent_index) return false; } - if(p != i-1) { + if(p != decltype(p)(i-1)) { // we have a branch and i-1 is a leaf node is_leaf[i-1] = true; } @@ -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, @@ -174,7 +174,7 @@ std::vector<typename C::value_type> branches(const C& parent_index) "integral type required" ); - EXPECTS(has_contiguous_segments(parent_index)); + //EXPECTS(has_contiguous_segments(parent_index)); std::vector<typename C::value_type> branch_index; if (parent_index.empty()) { @@ -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; @@ -250,7 +250,7 @@ std::vector<typename C::value_type> make_parent_index( } EXPECTS(parent_index.size() == unsigned(branch_index.back())); - EXPECTS(has_contiguous_segments(parent_index)); + //EXPECTS(has_contiguous_segments(parent_index)); EXPECTS(is_strictly_monotonic_increasing(branch_index)); // expand the branch index 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/communication/communicator.hpp b/src/communication/communicator.hpp index 7a9ee094b59cb53708cfa291bae6f3f2b9c76ece..d73f4dcdbac22d4986b3d59fcefb6a66e4aae357 100644 --- a/src/communication/communicator.hpp +++ b/src/communication/communicator.hpp @@ -97,17 +97,13 @@ public: return communication_policy_.min(local_min); } - std::vector<event_queue> exchange(const local_spike_store_type& spikes) { - // global all-to-all to gather a local copy of the global spike list - // on each node - auto global_spikes = - communication_policy_.gather_spikes( - merge_spike_store(spikes) - ); + std::vector<event_queue> exchange(const std::vector<spike_type>& local_spikes) { + // global all-to-all to gather a local copy of the global spike list on each node. + auto global_spikes = communication_policy_.gather_spikes( local_spikes ); num_spikes_ += global_spikes.size(); - // Check each global spike in turn to see it generates local events. - // If so, make the events and insert them into the appropriate event list + // check each global spike in turn to see it generates local events. + // if so, make the events and insert them into the appropriate event list. auto queues = std::vector<event_queue>(num_groups_local()); for (auto spike : global_spikes) { // search for targets @@ -137,14 +133,6 @@ public: } private: - std::vector<spike_type> merge_spike_store(const local_spike_store_type& buffers) { - std::vector<spike_type> spikes; - for (auto& v : buffers) { - spikes.insert(spikes.end(), v.begin(), v.end()); - } - return spikes; - } - std::size_t cell_group_index(cell_gid_type cell_gid) const { // this will be more elaborate when there is more than one cell per cell group EXPECTS(cell_gid>=cell_gid_from_ && cell_gid<cell_gid_to_); 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 019633387bc259ba1079f46fd20f3819abc52df4..5479d2ed5150d3e0b4cb965ff2887084ec305f99 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -15,6 +15,55 @@ namespace nest { namespace mc { +template <typename Time> +class thread_private_spike_store { +public : + using id_type = cell_gid_type; + using time_type = Time; + using spike_type = spike<cell_member_type, time_type>; + + std::vector<spike_type> gather() const { + std::vector<spike_type> spikes; + unsigned num_spikes = 0u; + for (auto& b : buffers_) { + num_spikes += b.size(); + } + spikes.reserve(num_spikes); + + for (auto& b : buffers_) { + spikes.insert(spikes.begin(), b.begin(), b.end()); + } + + return spikes; + } + + std::vector<spike_type>& get() { + return buffers_.local(); + } + + const std::vector<spike_type>& get() const { + return buffers_.local(); + } + + void clear() { + for (auto& b : buffers_) { + b.clear(); + } + } + + void insert(const std::vector<spike_type>& spikes) { + auto& buff = get(); + buff.insert(buff.begin(), spikes.begin(), spikes.end()); + } + +private : + /// thread private storage for accumulating spikes + using local_spike_store_type = + threading::enumerable_thread_specific<std::vector<spike_type>>; + + local_spike_store_type buffers_; +}; + template <typename Cell> class model { public: @@ -29,14 +78,15 @@ 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) { + // generate the cell groups in parallel, with one task per cell group cell_groups_ = std::vector<cell_group_type>{cell_to_-cell_from_}; - threading::parallel_vector<probe_record> probes; + threading::parallel_for::apply(cell_from_, cell_to_, [&](cell_gid_type i) { PE("setup", "cells"); @@ -52,8 +102,10 @@ public: PL(2); }); + // insert probes probes_.assign(probes.begin(), probes.end()); + // generate the network connections for (cell_gid_type i=cell_from_; i<cell_to_; ++i) { for (const auto& cc: rec.connections_on(i)) { connection<time_type> conn{cc.source, cc.dest, cc.weight, cc.delay}; @@ -61,6 +113,12 @@ public: } } communicator_.construct(); + + // Allocate an empty queue buffer for each cell group + // These must be set initially to ensure that a queue is available for each + // cell group for the first time step. + current_events().resize(num_groups()); + future_events().resize(num_groups()); } void reset() { @@ -72,17 +130,20 @@ public: } time_type run(time_type tfinal, time_type dt) { - time_type min_delay = communicator_.min_delay(); + time_type min_delay = communicator_.min_delay()/2; while (t_<tfinal) { auto tuntil = std::min(t_+min_delay, tfinal); event_queues_.exchange(); local_spikes_.exchange(); + // empty the spike buffers for the current integration period. + // these buffers will store the new spikes generated in update_cells. + current_spikes().clear(); + + // TODO this needs a threading wrapper tbb::task_group g; - // should this take a reference to the input event queue - // and return a reference to the spikes? auto update_cells = [&] () { threading::parallel_for::apply( 0u, cell_groups_.size(), @@ -96,7 +157,7 @@ public: group.advance(tuntil, dt); PE("events"); - buffer_spikes(group.spikes()); + current_spikes().insert(group.spikes()); group.clear_spikes(); PL(2); }); @@ -104,7 +165,8 @@ public: auto exchange = [&] () { PE("stepping", "exchange"); - future_events() = communicator_.exchange(current_spikes()); + auto local_spikes = previous_spikes().gather(); + future_events() = communicator_.exchange(local_spikes); PL(2); }; @@ -124,7 +186,7 @@ public: } void add_artificial_spike(cell_member_type source, time_type tspike) { - previous_spikes().local().push_back({source, tspike}); + current_spikes().get().push_back({source, tspike}); } void attach_sampler(cell_member_type probe_id, sampler_function f, time_type tfrom = 0) { @@ -138,6 +200,7 @@ public: const std::vector<probe_record>& probes() const { return probes_; } std::size_t num_spikes() const { return communicator_.num_spikes(); } + std::size_t num_groups() const { return cell_groups_.size(); } private: cell_gid_type cell_from_; @@ -151,18 +214,13 @@ private: using event_queue_type = typename communicator_type::event_queue; util::double_buffer< std::vector<event_queue_type> > event_queues_; - using local_spike_store_type = typename communicator_type::local_spike_store_type; + using local_spike_store_type = thread_private_spike_store<time_type>; util::double_buffer< local_spike_store_type > local_spikes_; local_spike_store_type& current_spikes() { return local_spikes_.get(); } local_spike_store_type& previous_spikes() { return local_spikes_.other(); } std::vector<event_queue_type>& current_events() { return event_queues_.get(); } std::vector<event_queue_type>& future_events() { return event_queues_.other(); } - - void buffer_spikes(const std::vector<spike_type>& s) { - auto& buff = current_spikes().local(); - buff.insert(buff.end(), s.begin(), s.end()); - } }; } // namespace mc 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_compartments.cpp b/tests/unit/test_compartments.cpp index 3ca0acbcabf995637b77c79173431e34e449617f..c167b16cce5585a43efc13fc9f136025b21f7811 100644 --- a/tests/unit/test_compartments.cpp +++ b/tests/unit/test_compartments.cpp @@ -108,11 +108,11 @@ TEST(compartments, compartment_range) { nest::mc::compartment_range rng(10, 1.0, 2.0, 10.); - EXPECT_EQ((*rng.begin()).index, 0); - EXPECT_EQ((*rng.end()).index, 10); + EXPECT_EQ((*rng.begin()).index, 0u); + EXPECT_EQ((*rng.end()).index, 10u); EXPECT_NE(rng.begin(), rng.end()); - int count = 0; + unsigned count = 0; for(auto c : rng) { EXPECT_EQ(c.index, count); auto er = 1.0 + double(count)/10.; @@ -121,7 +121,7 @@ TEST(compartments, compartment_range) EXPECT_EQ(c.length, 1.0); ++count; } - EXPECT_EQ(count, 10); + EXPECT_EQ(count, 10u); } // test case of zero length range 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);