diff options
author | David Shah <davey1576@gmail.com> | 2018-06-23 16:12:52 +0200 |
---|---|---|
committer | David Shah <davey1576@gmail.com> | 2018-06-23 16:12:52 +0200 |
commit | 1e8840b0f9400a1dc17ba6c7496314f82f0db2e1 (patch) | |
tree | 73e00ef273a99badcb10c08e28188ab4061d0f47 /common | |
parent | 727f99267caf3de2d3884f00ac61fad1175705fc (diff) | |
download | nextpnr-1e8840b0f9400a1dc17ba6c7496314f82f0db2e1.tar.gz nextpnr-1e8840b0f9400a1dc17ba6c7496314f82f0db2e1.tar.bz2 nextpnr-1e8840b0f9400a1dc17ba6c7496314f82f0db2e1.zip |
Update from increased clangformat line length
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/design_utils.cc | 6 | ||||
-rw-r--r-- | common/design_utils.h | 17 | ||||
-rw-r--r-- | common/place_sa.cc | 72 | ||||
-rw-r--r-- | common/pybindings.cc | 20 | ||||
-rw-r--r-- | common/pybindings.h | 19 | ||||
-rw-r--r-- | common/pycontainers.h | 43 | ||||
-rw-r--r-- | common/timing.cc | 32 | ||||
-rw-r--r-- | common/util.h | 9 |
8 files changed, 70 insertions, 148 deletions
diff --git a/common/design_utils.cc b/common/design_utils.cc index 28237b35..640a18a2 100644 --- a/common/design_utils.cc +++ b/common/design_utils.cc @@ -24,8 +24,7 @@ #include "util.h" NEXTPNR_NAMESPACE_BEGIN -void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, - IdString rep_name) +void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, IdString rep_name) { PortInfo &old = old_cell->ports.at(old_name); PortInfo &rep = rep_cell->ports.at(rep_name); @@ -69,8 +68,7 @@ void print_utilisation(const Context *ctx) for (auto type : available_types) { IdString type_id = ctx->belTypeToId(type.first); int used_bels = get_or_default(used_types, type.first, 0); - log_info("\t%20s: %5d/%5d %5d%%\n", type_id.c_str(ctx), used_bels, - type.second, 100 * used_bels / type.second); + log_info("\t%20s: %5d/%5d %5d%%\n", type_id.c_str(ctx), used_bels, type.second, 100 * used_bels / type.second); } log_break(); } diff --git a/common/design_utils.h b/common/design_utils.h index 13e4ec1d..cb802a1a 100644 --- a/common/design_utils.h +++ b/common/design_utils.h @@ -32,8 +32,7 @@ Utilities for design manipulation, intended for use inside packing algorithms */ // Disconnect a net (if connected) from old, and connect it to rep -void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, - IdString rep_name); +void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, IdString rep_name); // If a net drives a given port of a cell matching a predicate (in many // cases more than one cell type, e.g. SB_DFFxx so a predicate is used), return @@ -41,8 +40,7 @@ void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, // true, then this cell must be the only load. If ignore_cell is set, that cell // is not considered template <typename F1> -CellInfo *net_only_drives(const Context *ctx, NetInfo *net, F1 cell_pred, - IdString port, bool exclusive = false, +CellInfo *net_only_drives(const Context *ctx, NetInfo *net, F1 cell_pred, IdString port, bool exclusive = false, CellInfo *exclude = nullptr) { if (net == nullptr) @@ -56,16 +54,13 @@ CellInfo *net_only_drives(const Context *ctx, NetInfo *net, F1 cell_pred, return nullptr; } else if (net->users.size() == 2) { if (std::find_if(net->users.begin(), net->users.end(), - [exclude](const PortRef &ref) { - return ref.cell == exclude; - }) == net->users.end()) + [exclude](const PortRef &ref) { return ref.cell == exclude; }) == net->users.end()) return nullptr; } } } for (const auto &load : net->users) { - if (load.cell != exclude && cell_pred(ctx, load.cell) && - load.port == port) { + if (load.cell != exclude && cell_pred(ctx, load.cell) && load.port == port) { return load.cell; } } @@ -74,9 +69,7 @@ CellInfo *net_only_drives(const Context *ctx, NetInfo *net, F1 cell_pred, // If a net is driven by a given port of a cell matching a predicate, return // that cell, otherwise nullptr -template <typename F1> -CellInfo *net_driven_by(const Context *ctx, const NetInfo *net, F1 cell_pred, - IdString port) +template <typename F1> CellInfo *net_driven_by(const Context *ctx, const NetInfo *net, F1 cell_pred, IdString port) { if (net == nullptr) return nullptr; diff --git a/common/place_sa.cc b/common/place_sa.cc index f4fb5aff..a12e409b 100644 --- a/common/place_sa.cc +++ b/common/place_sa.cc @@ -88,19 +88,17 @@ class SAPlacer std::string loc_name = loc->second; BelId bel = ctx->getBelByName(ctx->id(loc_name)); if (bel == BelId()) { - log_error( - "No Bel named \'%s\' located for " - "this chip (processing BEL attribute on \'%s\')\n", - loc_name.c_str(), cell->name.c_str(ctx)); + log_error("No Bel named \'%s\' located for " + "this chip (processing BEL attribute on \'%s\')\n", + loc_name.c_str(), cell->name.c_str(ctx)); } BelType bel_type = ctx->getBelType(bel); if (bel_type != ctx->belTypeFromId(cell->type)) { log_error("Bel \'%s\' of type \'%s\' does not match cell " "\'%s\' of type \'%s\'", - loc_name.c_str(), - ctx->belTypeToId(bel_type).c_str(ctx), - cell->name.c_str(ctx), cell->type.c_str(ctx)); + loc_name.c_str(), ctx->belTypeToId(bel_type).c_str(ctx), cell->name.c_str(ctx), + cell->type.c_str(ctx)); } ctx->bindBel(bel, cell->name, STRENGTH_USER); @@ -119,25 +117,21 @@ class SAPlacer autoplaced.push_back(cell.second); } } - std::sort(autoplaced.begin(), autoplaced.end(), - [](CellInfo *a, CellInfo *b) { return a->name < b->name; }); + std::sort(autoplaced.begin(), autoplaced.end(), [](CellInfo *a, CellInfo *b) { return a->name < b->name; }); ctx->shuffle(autoplaced); // Place cells randomly initially - log_info("Creating initial placement for remaining %d cells.\n", - int(autoplaced.size())); + log_info("Creating initial placement for remaining %d cells.\n", int(autoplaced.size())); for (auto cell : autoplaced) { place_initial(cell); placed_cells++; if ((placed_cells - constr_placed_cells) % 500 == 0) - log_info(" initial placement placed %d/%d cells\n", - int(placed_cells - constr_placed_cells), + log_info(" initial placement placed %d/%d cells\n", int(placed_cells - constr_placed_cells), int(autoplaced.size())); } if ((placed_cells - constr_placed_cells) % 500 != 0) - log_info(" initial placement placed %d/%d cells\n", - int(placed_cells - constr_placed_cells), + log_info(" initial placement placed %d/%d cells\n", int(placed_cells - constr_placed_cells), int(autoplaced.size())); log_info("Running simulated annealing placer.\n"); @@ -184,9 +178,7 @@ class SAPlacer if (temp <= 1e-3 && n_no_progress >= 5) { if (iter % 5 != 0) - log_info( - " at iteration #%d: temp = %f, wire length = %f\n", - iter, temp, double(curr_wirelength)); + log_info(" at iteration #%d: temp = %f, wire length = %f\n", iter, temp, double(curr_wirelength)); break; } @@ -235,15 +227,13 @@ class SAPlacer if (cell != IdString()) cell_text = std::string("cell '") + cell.str(ctx) + "'"; if (ctx->force) { - log_warning( - "post-placement validity check failed for Bel '%s' " - "(%s)\n", - ctx->getBelName(bel).c_str(ctx), cell_text.c_str()); + log_warning("post-placement validity check failed for Bel '%s' " + "(%s)\n", + ctx->getBelName(bel).c_str(ctx), cell_text.c_str()); } else { - log_error( - "post-placement validity check failed for Bel '%s' " - "(%s)\n", - ctx->getBelName(bel).c_str(ctx), cell_text.c_str()); + log_error("post-placement validity check failed for Bel '%s' " + "(%s)\n", + ctx->getBelName(bel).c_str(ctx), cell_text.c_str()); } } } @@ -267,8 +257,7 @@ class SAPlacer } BelType targetType = ctx->belTypeFromId(cell->type); for (auto bel : ctx->getBels()) { - if (ctx->getBelType(bel) == targetType && - checker->isValidBelForCell(cell, bel)) { + if (ctx->getBelType(bel) == targetType && checker->isValidBelForCell(cell, bel)) { if (ctx->checkBelAvail(bel)) { uint64_t score = ctx->rng64(); if (score <= best_score) { @@ -279,8 +268,7 @@ class SAPlacer uint64_t score = ctx->rng64(); if (score <= best_ripup_score) { best_ripup_score = score; - ripup_target = - ctx->cells.at(ctx->getBoundBelCell(bel)); + ripup_target = ctx->cells.at(ctx->getBoundBelCell(bel)); ripup_bel = bel; } } @@ -288,8 +276,7 @@ class SAPlacer } if (best_bel == BelId()) { if (iters == 0 || ripup_bel == BelId()) - log_error("failed to place cell '%s' of type '%s'\n", - cell->name.c_str(ctx), cell->type.c_str(ctx)); + log_error("failed to place cell '%s' of type '%s'\n", cell->name.c_str(ctx), cell->type.c_str(ctx)); --iters; ctx->unbindBel(ripup_target->bel); best_bel = ripup_bel; @@ -316,8 +303,7 @@ class SAPlacer if (driver_cell->bel == BelId()) return 0; ctx->estimatePosition(driver_cell->bel, driver_x, driver_y, driver_gb); - WireId drv_wire = ctx->getWireBelPin( - driver_cell->bel, ctx->portPinFromId(net->driver.port)); + WireId drv_wire = ctx->getWireBelPin(driver_cell->bel, ctx->portPinFromId(net->driver.port)); if (driver_gb) return 0; float worst_slack = 1000; @@ -329,11 +315,9 @@ class SAPlacer if (load_cell->bel == BelId()) continue; if (timing_driven) { - WireId user_wire = ctx->getWireBelPin( - load_cell->bel, ctx->portPinFromId(load.port)); + WireId user_wire = ctx->getWireBelPin(load_cell->bel, ctx->portPinFromId(load.port)); delay_t raw_wl = ctx->estimateDelay(drv_wire, user_wire); - float slack = - ctx->getDelayNS(load.budget) - ctx->getDelayNS(raw_wl); + float slack = ctx->getDelayNS(load.budget) - ctx->getDelayNS(raw_wl); if (slack < 0) tns += slack; worst_slack = std::min(slack, worst_slack); @@ -351,11 +335,9 @@ class SAPlacer } if (timing_driven) { wirelength = - wirelen_t((((ymax - ymin) + (xmax - xmin)) * - std::min(5.0, (1.0 + std::exp(-worst_slack / 5))))); + wirelen_t((((ymax - ymin) + (xmax - xmin)) * std::min(5.0, (1.0 + std::exp(-worst_slack / 5))))); } else { - wirelength = - wirelen_t((ymax - ymin) + (xmax - xmin)); + wirelength = wirelen_t((ymax - ymin) + (xmax - xmin)); } return wirelength; @@ -394,8 +376,7 @@ class SAPlacer ctx->bindBel(oldBel, other_cell->name, STRENGTH_WEAK); } - if (!checker->isBelLocationValid(newBel) || - ((other != IdString() && !checker->isBelLocationValid(oldBel)))) { + if (!checker->isBelLocationValid(newBel) || ((other != IdString() && !checker->isBelLocationValid(oldBel)))) { ctx->unbindBel(newBel); if (other != IdString()) ctx->unbindBel(oldBel); @@ -415,8 +396,7 @@ class SAPlacer delta = new_wirelength - curr_wirelength; n_move++; // SA acceptance criterea - if (delta < 0 || (temp > 1e-6 && (ctx->rng() / float(0x3fffffff)) <= - std::exp(-delta / temp))) { + if (delta < 0 || (temp > 1e-6 && (ctx->rng() / float(0x3fffffff)) <= std::exp(-delta / temp))) { n_accept++; if (delta < 2) improved = true; diff --git a/common/pybindings.cc b/common/pybindings.cc index b67320a2..cc4ad006 100644 --- a/common/pybindings.cc +++ b/common/pybindings.cc @@ -43,10 +43,7 @@ NEXTPNR_NAMESPACE_BEGIN // must be implemented in all architectures void arch_wrap_python(); -bool operator==(const PortRef &a, const PortRef &b) -{ - return (a.cell == b.cell) && (a.port == b.port); -} +bool operator==(const PortRef &a, const PortRef &b) { return (a.cell == b.cell) && (a.port == b.port); } // Load a JSON file into a design void parse_json_shim(std::string filename, Context &d) @@ -75,9 +72,7 @@ BOOST_PYTHON_MODULE(MODULE_NAME) .def_readwrite("y2", &GraphicElement::y2) .def_readwrite("text", &GraphicElement::text); - class_<PortRef>("PortRef") - .def_readwrite("cell", &PortRef::cell) - .def_readwrite("port", &PortRef::port); + class_<PortRef>("PortRef").def_readwrite("cell", &PortRef::cell).def_readwrite("port", &PortRef::port); class_<NetInfo, NetInfo *>("NetInfo") .def_readwrite("name", &NetInfo::name) @@ -88,8 +83,7 @@ BOOST_PYTHON_MODULE(MODULE_NAME) WRAP_MAP(decltype(NetInfo::attrs), "IdStrMap"); - class_<std::vector<PortRef>>("PortRefVector") - .def(vector_indexing_suite<std::vector<PortRef>>()); + class_<std::vector<PortRef>>("PortRefVector").def(vector_indexing_suite<std::vector<PortRef>>()); enum_<PortType>("PortType") .value("PORT_IN", PORT_IN) @@ -125,17 +119,13 @@ BOOST_PYTHON_MODULE(MODULE_NAME) def("load_design", load_design_shim); class_<IdString>("IdString") - .def("__str__", &IdString::global_str, - return_value_policy<copy_const_reference>()) + .def("__str__", &IdString::global_str, return_value_policy<copy_const_reference>()) .def(self < self) .def(self == self); arch_wrap_python(); } -void arch_appendinittab() -{ - PyImport_AppendInittab(TOSTRING(MODULE_NAME), PYINIT_MODULE_NAME); -} +void arch_appendinittab() { PyImport_AppendInittab(TOSTRING(MODULE_NAME), PYINIT_MODULE_NAME); } static wchar_t *program; diff --git a/common/pybindings.h b/common/pybindings.h index 4379a1aa..1f5ca004 100644 --- a/common/pybindings.h +++ b/common/pybindings.h @@ -45,26 +45,18 @@ template <typename T> struct string_wrapper { from_pystring_converter() { - converter::registry::push_back(&convertible, &construct, - boost::python::type_id<T>()); + converter::registry::push_back(&convertible, &construct, boost::python::type_id<T>()); }; - static void *convertible(PyObject *object) - { - return PyUnicode_Check(object) ? object : 0; - } + static void *convertible(PyObject *object) { return PyUnicode_Check(object) ? object : 0; } - static void construct(PyObject *object, - converter::rvalue_from_python_stage1_data *data) + static void construct(PyObject *object, converter::rvalue_from_python_stage1_data *data) { const wchar_t *value = PyUnicode_AsUnicode(object); const std::wstring value_ws(value); if (value == 0) throw_error_already_set(); - void *storage = - ((boost::python::converter::rvalue_from_python_storage<T> *) - data) - ->storage.bytes; + void *storage = ((boost::python::converter::rvalue_from_python_storage<T> *)data)->storage.bytes; new (storage) T(fn(std::string(value_ws.begin(), value_ws.end()))); data->convertible = storage; } @@ -79,8 +71,7 @@ template <typename T> struct string_wrapper std::string str(T &x) { return fn(x); } }; - template <typename F1, typename F2> - static void wrap(const char *type_name, F1 to_str_fn, F2 from_str_fn) + template <typename F1, typename F2> static void wrap(const char *type_name, F1 to_str_fn, F2 from_str_fn) { from_pystring_converter<F2>::fn = from_str_fn; from_pystring_converter<F2>(); diff --git a/common/pycontainers.h b/common/pycontainers.h index 06e772a0..85a19fba 100644 --- a/common/pycontainers.h +++ b/common/pycontainers.h @@ -61,8 +61,7 @@ template <typename T, typename P> struct iterator_wrapper static void wrap(const char *python_name) { - class_<std::pair<T, T>>(python_name, no_init) - .def("__next__", next, P()); + class_<std::pair<T, T>>(python_name, no_init).def("__next__", next, P()); } }; @@ -72,15 +71,11 @@ and end() which return iterator-like objects supporting ++, * and != Full STL iterator semantics are not required, unlike the standard Boost wrappers */ -template <typename T, typename P = return_value_policy<return_by_value>> -struct range_wrapper +template <typename T, typename P = return_value_policy<return_by_value>> struct range_wrapper { typedef decltype(std::declval<T>().begin()) iterator_t; - static std::pair<iterator_t, iterator_t> iter(T &range) - { - return std::make_pair(range.begin(), range.end()); - } + static std::pair<iterator_t, iterator_t> iter(T &range) { return std::make_pair(range.begin(), range.end()); } static void wrap(const char *range_name, const char *iter_name) { @@ -122,8 +117,7 @@ template <typename T1, typename T2> struct pair_wrapper static void wrap(const char *python_name) { - class_<std::pair<T &, int>>(python_name, no_init) - .def("__next__", next); + class_<std::pair<T &, int>>(python_name, no_init).def("__next__", next); } }; @@ -146,10 +140,7 @@ template <typename T1, typename T2> struct pair_wrapper static int len(T &x) { return 2; } - static std::pair<T &, int> iter(T &x) - { - return std::make_pair(boost::ref(x), 0); - }; + static std::pair<T &, int> iter(T &x) { return std::make_pair(boost::ref(x), 0); }; static void wrap(const char *pair_name, const char *iter_name) { @@ -192,8 +183,7 @@ template <typename T1, typename T2> struct map_pair_wrapper static void wrap(const char *python_name) { - class_<std::pair<T &, int>>(python_name, no_init) - .def("__next__", next); + class_<std::pair<T &, int>>(python_name, no_init).def("__next__", next); } }; @@ -206,10 +196,7 @@ template <typename T1, typename T2> struct map_pair_wrapper static int len(T &x) { return 2; } - static std::pair<T &, int> iter(T &x) - { - return std::make_pair(boost::ref(x), 0); - }; + static std::pair<T &, int> iter(T &x) { return std::make_pair(boost::ref(x), 0); }; static void wrap(const char *pair_name, const char *iter_name) { @@ -229,8 +216,7 @@ Wrapper for a map, either an unordered_map, regular map or dict template <typename T> struct map_wrapper { - typedef typename std::remove_cv< - typename std::remove_reference<typename T::key_type>::type>::type K; + typedef typename std::remove_cv<typename std::remove_reference<typename T::key_type>::type>::type K; typedef typename T::mapped_type V; typedef typename T::value_type KV; @@ -253,13 +239,10 @@ template <typename T> struct map_wrapper std::terminate(); } - static void wrap(const char *map_name, const char *kv_name, - const char *kv_iter_name, const char *iter_name) + static void wrap(const char *map_name, const char *kv_name, const char *kv_iter_name, const char *iter_name) { - map_pair_wrapper<typename KV::first_type, - typename KV::second_type>::wrap(kv_name, kv_iter_name); - typedef range_wrapper<T, return_value_policy<copy_non_const_reference>> - rw; + map_pair_wrapper<typename KV::first_type, typename KV::second_type>::wrap(kv_name, kv_iter_name); + typedef range_wrapper<T, return_value_policy<copy_non_const_reference>> rw; typename rw::iter_wrap().wrap(iter_name); class_<T>(map_name, no_init) .def("__iter__", rw::iter) @@ -269,9 +252,7 @@ template <typename T> struct map_wrapper } }; -#define WRAP_MAP(t, name) \ - map_wrapper<t>().wrap(#name, #name "KeyValue", #name "KeyValueIter", \ - #name "Iterator") +#define WRAP_MAP(t, name) map_wrapper<t>().wrap(#name, #name "KeyValue", #name "KeyValueIter", #name "Iterator") NEXTPNR_NAMESPACE_END diff --git a/common/timing.cc b/common/timing.cc index ac116711..0684c543 100644 --- a/common/timing.cc +++ b/common/timing.cc @@ -25,12 +25,10 @@ NEXTPNR_NAMESPACE_BEGIN -static delay_t follow_net(Context *ctx, NetInfo *net, int path_length, - delay_t slack); +static delay_t follow_net(Context *ctx, NetInfo *net, int path_length, delay_t slack); // Follow a path, returning budget to annotate -static delay_t follow_user_port(Context *ctx, PortRef &user, int path_length, - delay_t slack) +static delay_t follow_user_port(Context *ctx, PortRef &user, int path_length, delay_t slack) { delay_t value; if (ctx->getPortClock(user.cell, user.port) != IdString()) { @@ -45,13 +43,11 @@ static delay_t follow_user_port(Context *ctx, PortRef &user, int path_length, if (port.second.type == PORT_OUT) { delay_t comb_delay; // Look up delay through this path - bool is_path = ctx->getCellDelay(user.cell, user.port, - port.first, comb_delay); + bool is_path = ctx->getCellDelay(user.cell, user.port, port.first, comb_delay); if (is_path) { NetInfo *net = port.second.net; if (net) { - delay_t path_budget = follow_net(ctx, net, path_length, - slack - comb_delay); + delay_t path_budget = follow_net(ctx, net, path_length, slack - comb_delay); value = std::min(value, path_budget); } } @@ -65,13 +61,11 @@ static delay_t follow_user_port(Context *ctx, PortRef &user, int path_length, return value; } -static delay_t follow_net(Context *ctx, NetInfo *net, int path_length, - delay_t slack) +static delay_t follow_net(Context *ctx, NetInfo *net, int path_length, delay_t slack) { delay_t net_budget = slack / (path_length + 1); for (auto &usr : net->users) { - net_budget = std::min( - net_budget, follow_user_port(ctx, usr, path_length + 1, slack)); + net_budget = std::min(net_budget, follow_user_port(ctx, usr, path_length + 1, slack)); } return net_budget; } @@ -91,11 +85,9 @@ void assign_budget(Context *ctx, float default_clock) for (auto cell : ctx->cells) { for (auto port : cell.second->ports) { if (port.second.type == PORT_OUT) { - IdString clock_domain = - ctx->getPortClock(cell.second, port.first); + IdString clock_domain = ctx->getPortClock(cell.second, port.first); if (clock_domain != IdString()) { - delay_t slack = delay_t( - 1.0e12 / default_clock); // TODO: clock constraints + delay_t slack = delay_t(1.0e12 / default_clock); // TODO: clock constraints if (port.second.net) follow_net(ctx, port.second.net, 0, slack); } @@ -109,13 +101,13 @@ void assign_budget(Context *ctx, float default_clock) if (user.budget < 0) log_warning("port %s.%s, connected to net '%s', has negative " "timing budget of %fns\n", - user.cell->name.c_str(ctx), user.port.c_str(ctx), - net.first.c_str(ctx), ctx->getDelayNS(user.budget)); + user.cell->name.c_str(ctx), user.port.c_str(ctx), net.first.c_str(ctx), + ctx->getDelayNS(user.budget)); if (ctx->verbose) log_info("port %s.%s, connected to net '%s', has " "timing budget of %fns\n", - user.cell->name.c_str(ctx), user.port.c_str(ctx), - net.first.c_str(ctx), ctx->getDelayNS(user.budget)); + user.cell->name.c_str(ctx), user.port.c_str(ctx), net.first.c_str(ctx), + ctx->getDelayNS(user.budget)); } } diff --git a/common/util.h b/common/util.h index 4c60292b..5e938635 100644 --- a/common/util.h +++ b/common/util.h @@ -29,8 +29,7 @@ NEXTPNR_NAMESPACE_BEGIN // Get a value from a map-style container, returning default if value is not // found template <typename Container, typename KeyType, typename ValueType> -ValueType get_or_default(const Container &ct, const KeyType &key, - ValueType def = ValueType()) +ValueType get_or_default(const Container &ct, const KeyType &key, ValueType def = ValueType()) { auto found = ct.find(key); if (found == ct.end()) @@ -41,8 +40,7 @@ ValueType get_or_default(const Container &ct, const KeyType &key, // Get a value from a map-style container, converting to int, and returning // default if value is not found -template <typename Container, typename KeyType> -int int_or_default(const Container &ct, const KeyType &key, int def = 0) +template <typename Container, typename KeyType> int int_or_default(const Container &ct, const KeyType &key, int def = 0) { auto found = ct.find(key); if (found == ct.end()) @@ -59,8 +57,7 @@ bool bool_or_default(const Container &ct, const KeyType &key, bool def = false) }; // Wrap an unordered_map, and allow it to be iterated over sorted by key -template <typename K, typename V> -std::map<K, V> sorted(const std::unordered_map<K, V> &orig) +template <typename K, typename V> std::map<K, V> sorted(const std::unordered_map<K, V> &orig) { return std::map<K, V>(orig.begin(), orig.end()); }; |