From 6eded9bf1adf1d3148cd05e05c9d9396fb99204f Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Thu, 2 Sep 2021 18:02:07 +0200 Subject: [PATCH] [BL] clang-format. --- BaseLib/Algorithm.h | 13 +- BaseLib/CPUTime.h | 25 ++- BaseLib/ConfigTree-impl.h | 105 ++++++------- BaseLib/ConfigTree.h | 306 ++++++++++++++++++++---------------- BaseLib/DateTools.h | 12 +- BaseLib/Error.h | 2 +- BaseLib/ExportSymbol.h | 12 +- BaseLib/FileTools.h | 13 +- BaseLib/Histogram.h | 33 ++-- BaseLib/MemWatch.h | 13 +- BaseLib/Stream.h | 5 +- BaseLib/StringTools.h | 26 +-- BaseLib/Subdivision.h | 10 +- BaseLib/TCLAPCustomOutput.h | 105 ++++++------- BaseLib/quicksort.h | 53 +++---- 15 files changed, 376 insertions(+), 357 deletions(-) diff --git a/BaseLib/Algorithm.h b/BaseLib/Algorithm.h index edfb6046759..98ccae5406b 100644 --- a/BaseLib/Algorithm.h +++ b/BaseLib/Algorithm.h @@ -21,7 +21,6 @@ namespace BaseLib { - /// excludeObjectCopy copies only those objects that position within the source /// vector is not in the exclude_positions vector. The implementation of the /// algorithm requires that the given positions in exclude_positions are sorted @@ -122,9 +121,8 @@ template <typename Map, typename Key, typename Value> void insertIfKeyValueUniqueElseError(Map& map, Key const& key, Value&& value, std::string const& error_message) { - auto value_compare = [&value](typename Map::value_type const& elem) { - return value == elem.second; - }; + auto value_compare = [&value](typename Map::value_type const& elem) + { return value == elem.second; }; if (std::find_if(map.cbegin(), map.cend(), value_compare) != map.cend()) { @@ -237,7 +235,7 @@ void reorderVector(std::vector<ValueType>& v, std::vector<ValueType> temp_v(v.size()); temp_v.swap(v); - for (std::size_t i=0; i<order.size(); i++) + for (std::size_t i = 0; i < order.size(); i++) { std::swap(v[i], temp_v[order[i]]); } @@ -275,9 +273,8 @@ std::optional<typename Container::value_type> findFirstNotEqualElement( { auto const it = std::find_if_not(container.begin(), container.end(), - [&element](typename Container::value_type const& e) { - return e == element; - }); + [&element](typename Container::value_type const& e) + { return e == element; }); return it == container.end() ? std::nullopt : std::make_optional(*it); } diff --git a/BaseLib/CPUTime.h b/BaseLib/CPUTime.h index 55d3f2b7f6e..13dc9df11c1 100644 --- a/BaseLib/CPUTime.h +++ b/BaseLib/CPUTime.h @@ -18,22 +18,21 @@ namespace BaseLib { - /// Count CPU time class CPUTime { - public: - /// Start the timer. - void start() { start_time_ = clock(); } +public: + /// Start the timer. + void start() { start_time_ = clock(); } + + /// Get the elapsed time after started. + double elapsed() const + { + return (clock() - start_time_) / static_cast<double>(CLOCKS_PER_SEC); + } - /// Get the elapsed time after started. - double elapsed() const - { - return (clock() - start_time_) / - static_cast<double>(CLOCKS_PER_SEC); - } - private: - double start_time_ = 0.; +private: + double start_time_ = 0.; }; -} // end namespace BaseLib +} // end namespace BaseLib diff --git a/BaseLib/ConfigTree-impl.h b/BaseLib/ConfigTree-impl.h index 4439d70f263..25b45389362 100644 --- a/BaseLib/ConfigTree-impl.h +++ b/BaseLib/ConfigTree-impl.h @@ -8,22 +8,22 @@ * */ -#include "ConfigTree.h" - #include <sstream> #include <utility> +#include "ConfigTree.h" + namespace BaseLib { - //! Wraps a pair of iterators for use as a range in range-based for-loops. -template<typename Iterator> +template <typename Iterator> class Range { public: explicit Range(Iterator begin, Iterator end) : begin_(std::move(begin)), end_(std::move(end)) - {} + { + } Iterator begin() const { return begin_; } Iterator end() const { return end_; } @@ -35,10 +35,8 @@ private: Iterator end_; }; -template<typename T> -T -ConfigTree:: -getConfigParameter(std::string const& param) const +template <typename T> +T ConfigTree::getConfigParameter(std::string const& param) const { if (auto p = getConfigParameterOptional<T>(param)) { @@ -48,10 +46,9 @@ getConfigParameter(std::string const& param) const error("Key <" + param + "> has not been found"); } -template<typename T> -T -ConfigTree:: -getConfigParameter(std::string const& param, T const& default_value) const +template <typename T> +T ConfigTree::getConfigParameter(std::string const& param, + T const& default_value) const { if (auto p = getConfigParameterOptional<T>(param)) { @@ -96,10 +93,9 @@ std::optional<std::vector<T>> ConfigTree::getConfigParameterOptionalImpl( result.push_back(value); } if (!sstr.eof()) // The stream is not read until the end, must be an - // error. result contains number of read values. + // error. result contains number of read values. { - error("Value for key <" + param + "> `" + - shortString(sstr.str()) + + error("Value for key <" + param + "> `" + shortString(sstr.str()) + "' not convertible to a vector of the desired type." " Could not convert token no. " + std::to_string(result.size() + 1) + "."); @@ -112,24 +108,20 @@ std::optional<std::vector<T>> ConfigTree::getConfigParameterOptionalImpl( return std::nullopt; } -template<typename T> -Range<ConfigTree::ValueIterator<T> > -ConfigTree:: -getConfigParameterList(std::string const& param) const +template <typename T> +Range<ConfigTree::ValueIterator<T>> ConfigTree::getConfigParameterList( + std::string const& param) const { checkUnique(param); markVisited<T>(param, Attr::TAG, true); auto p = tree_->equal_range(param); - return Range<ValueIterator<T> >( - ValueIterator<T>(p.first, param, *this), - ValueIterator<T>(p.second, param, *this)); + return Range<ValueIterator<T>>(ValueIterator<T>(p.first, param, *this), + ValueIterator<T>(p.second, param, *this)); } -template<typename T> -T -ConfigTree:: -peekConfigParameter(std::string const& param) const +template <typename T> +T ConfigTree::peekConfigParameter(std::string const& param) const { checkKeyname(param); @@ -151,30 +143,28 @@ peekConfigParameter(std::string const& param) const } } -template<typename T> -void -ConfigTree:: -checkConfigParameter(std::string const& param, T const& value) const +template <typename T> +void ConfigTree::checkConfigParameter(std::string const& param, + T const& value) const { - if (getConfigParameter<T>(param) != value) { + if (getConfigParameter<T>(param) != value) + { error("The value of key <" + param + "> is not the expected one."); } } -template<typename Ch> -void -ConfigTree:: -checkConfigParameter(std::string const& param, Ch const* value) const +template <typename Ch> +void ConfigTree::checkConfigParameter(std::string const& param, + Ch const* value) const { - if (getConfigParameter<std::string>(param) != value) { + if (getConfigParameter<std::string>(param) != value) + { error("The value of key <" + param + "> is not the expected one."); } } -template<typename T> -T -ConfigTree:: -getValue() const +template <typename T> +T ConfigTree::getValue() const { if (have_read_data_) { @@ -191,10 +181,8 @@ getValue() const "' is not convertible to the desired type."); } -template<typename T> -T -ConfigTree:: -getConfigAttribute(std::string const& attr) const +template <typename T> +T ConfigTree::getConfigAttribute(std::string const& attr) const { if (auto a = getConfigAttributeOptional<T>(attr)) { @@ -225,9 +213,11 @@ std::optional<T> ConfigTree::getConfigAttributeOptional( if (auto attrs = tree_->get_child_optional("<xmlattr>")) { - if (auto a = attrs->get_child_optional(attr)) { - ++ct.count; // count only if attribute has been found - if (auto v = a->get_value_optional<T>()) { + if (auto a = attrs->get_child_optional(attr)) + { + ++ct.count; // count only if attribute has been found + if (auto v = a->get_value_optional<T>()) + { return std::make_optional(*v); } error("Value for XML attribute '" + attr + "' `" + @@ -239,25 +229,28 @@ std::optional<T> ConfigTree::getConfigAttributeOptional( return std::nullopt; } -template<typename T> -ConfigTree::CountType& -ConfigTree:: -markVisited(std::string const& key, Attr const is_attr, - bool const peek_only) const +template <typename T> +ConfigTree::CountType& ConfigTree::markVisited(std::string const& key, + Attr const is_attr, + bool const peek_only) const { auto const type = std::type_index(typeid(T)); auto p = visited_params_.emplace(std::make_pair(is_attr, key), CountType{peek_only ? 0 : 1, type}); - if (!p.second) { // no insertion happened + if (!p.second) + { // no insertion happened auto& v = p.first->second; - if (v.type == type) { + if (v.type == type) + { if (!peek_only) { ++v.count; } - } else { + } + else + { error("There already was an attempt to obtain key <" + key + "> with type '" + v.type.name() + "' (now: '" + type.name() + "')."); diff --git a/BaseLib/ConfigTree.h b/BaseLib/ConfigTree.h index ff6002f6cac..a36db549f9d 100644 --- a/BaseLib/ConfigTree.h +++ b/BaseLib/ConfigTree.h @@ -10,23 +10,20 @@ #pragma once -#include <typeindex> -#include <map> - +#include <boost/property_tree/ptree.hpp> #include <functional> +#include <map> #include <memory> #include <optional> +#include <typeindex> #include <utility> #include <vector> -#include <boost/property_tree/ptree.hpp> - extern template class boost::property_tree::basic_ptree< std::string, std::string, std::less<>>; namespace BaseLib { - class ConfigTree; /*! Check if \c conf has been read entirely and invalidate it. @@ -43,66 +40,75 @@ void checkAndInvalidate(std::unique_ptr<ConfigTree> const& conf); //! \overload void checkAndInvalidate(ConfigTree& conf); -template<typename Iterator> class Range; +template <typename Iterator> +class Range; /*! - * Wrapper around a Boost Property Tree with some basic error reporting features. + * Wrapper around a Boost Property Tree with some basic error reporting + * features. * * Features. This class: * * makes sure that every configuration setting in a Property Tree is read - * exactly once. If some settings is not read (e.g. due to a typo), a warning message - * is generated. The message contains a hint where it occurred. + * exactly once. If some settings is not read (e.g. due to a typo), a warning + * message is generated. The message contains a hint where it occurred. * * enforces a naming scheme of settings: letters a-z, numbers 0-9, underscore - * * provides some functionality to read lists of values using range-based for loops. - * * has rather long method names that are easily greppable from the source code. So a list - * of supported configuration options can be easily obtained from the source code. + * * provides some functionality to read lists of values using range-based for + * loops. + * * has rather long method names that are easily greppable from the source + * code. So a list of supported configuration options can be easily obtained + * from the source code. * - * The purpose of this class is to reduce or completely avoid the amount of error-handling - * code in routines that take configuration parameters. + * The purpose of this class is to reduce or completely avoid the amount of + * error-handling code in routines that take configuration parameters. * - * Most methods of this class check that they have not been called before for the same - * \c ConfigTree and the same parameter. This behaviour helps to enforce that every parameter - * is read exactly once during parsing of the configuration settings. + * Most methods of this class check that they have not been called before for + * the same \c ConfigTree and the same parameter. This behaviour helps to + * enforce that every parameter is read exactly once during parsing of the + * configuration settings. * - * The most notable restriction of this class when compared to plain tree traversal is, that - * one must know all the XML tags (i.e. configuration parameters) at compile time. It is not - * possible to read from this class, which configuration parameters are present in the tree. - * This restriction, however, is intended, because it provides the possibility to get all - * existing configuration parameters from the source code. + * The most notable restriction of this class when compared to plain tree + * traversal is, that one must know all the XML tags (i.e. configuration + * parameters) at compile time. It is not possible to read from this class, + * which configuration parameters are present in the tree. This restriction, + * however, is intended, because it provides the possibility to get all existing + * configuration parameters from the source code. * - * This class maintains a read counter for each parameter accessed through any of its methods. - * Read counters are increased with every read (the only exception being the peekConfigParameter() method). - * The destructor finally decreases the read counter for every tag/attribute it find on the - * current level of the XML tree. If the increases/decreases don't cancel each other, warning - * messages are generated. This check can also be enforced before destruction by using the - * BaseLib::checkAndInvalidate() functions. + * This class maintains a read counter for each parameter accessed through any + * of its methods. Read counters are increased with every read (the only + * exception being the peekConfigParameter() method). The destructor finally + * decreases the read counter for every tag/attribute it find on the current + * level of the XML tree. If the increases/decreases don't cancel each other, + * warning messages are generated. This check can also be enforced before + * destruction by using the BaseLib::checkAndInvalidate() functions. * - * The design of this class entails some limitations compared to traversing a plain tree, - * e.g., it is not possible to obtain a list of tags or attributes from the tree, - * but one has to explicitly query the specific tags/attributes one is interested in. - * That way it is possible to get all used configuration parameters directly from the source - * code where this class is used, and to maintain the quality of the configuration parameter - * documentation. + * The design of this class entails some limitations compared to traversing a + * plain tree, e.g., it is not possible to obtain a list of tags or attributes + * from the tree, but one has to explicitly query the specific tags/attributes + * one is interested in. That way it is possible to get all used configuration + * parameters directly from the source code where this class is used, and to + * maintain the quality of the configuration parameter documentation. * - * Instances of this class only keep a reference to the underlying <tt>boost::property_tree</tt>. - * Therefore it is necessary that the underlying property tree stays intact as long as any - * instance---i.e. the top level ConfigTree and any of its children---reference it. - * In order to simplify the handling of this dependence, the class ConfigTreeTopLevel can be used. + * Instances of this class only keep a reference to the underlying + * <tt>boost::property_tree</tt>. Therefore it is necessary that the underlying + * property tree stays intact as long as any instance---i.e. the top level + * ConfigTree and any of its children---reference it. In order to simplify the + * handling of this dependence, the class ConfigTreeTopLevel can be used. * - * The construction of a ConfigTree from the content of an XML file can be done with the - * function BaseLib::makeConfigTree(), which performs many error checks. For limitations - * of the used XML parser, please have a look at that function's documentation. + * The construction of a ConfigTree from the content of an XML file can be done + * with the function BaseLib::makeConfigTree(), which performs many error + * checks. For limitations of the used XML parser, please have a look at that + * function's documentation. */ class ConfigTree final { public: /*! A wrapper around a Boost Iterator for iterating over ranges of subtrees. * - * The methods of this class tell the associated (parent) \c ConfigTree object when - * a setting has been parsed. + * The methods of this class tell the associated (parent) \c ConfigTree + * object when a setting has been parsed. */ class SubtreeIterator - : public std::iterator<std::input_iterator_tag, ConfigTree> + : public std::iterator<std::input_iterator_tag, ConfigTree> { public: using Iterator = boost::property_tree::ptree::const_assoc_iterator; @@ -110,15 +116,18 @@ public: explicit SubtreeIterator(Iterator const& it, std::string const& root, ConfigTree const& parent) : it_(it), tagname_(root), parent_(parent) - {} + { + } - SubtreeIterator& operator++() { + SubtreeIterator& operator++() + { ++it_; has_incremented_ = true; return *this; } - ConfigTree operator*() { + ConfigTree operator*() + { // if this iterator has been incremented since the last dereference, // tell the parent_ instance that a subtree now has been parsed. if (has_incremented_) @@ -129,11 +138,13 @@ public: return ConfigTree(it_->second, parent_, tagname_); } - bool operator==(SubtreeIterator const& other) const { + bool operator==(SubtreeIterator const& other) const + { return it_ == other.it_; } - bool operator!=(SubtreeIterator const& other) const { + bool operator!=(SubtreeIterator const& other) const + { return it_ != other.it_; } @@ -146,10 +157,11 @@ public: ConfigTree const& parent_; }; - /*! A wrapper around a Boost Iterator for iterating over ranges of parameters. + /*! A wrapper around a Boost Iterator for iterating over ranges of + * parameters. * - * The methods of this class tell the associated (parent) \c ConfigTree object when - * a setting has been parsed. + * The methods of this class tell the associated (parent) \c ConfigTree + * object when a setting has been parsed. */ class ParameterIterator : public SubtreeIterator { @@ -157,7 +169,8 @@ public: //! Inherit the constructor using SubtreeIterator::SubtreeIterator; - ConfigTree operator*() { + ConfigTree operator*() + { auto st = SubtreeIterator::operator*(); if (st.hasChildren()) { @@ -168,16 +181,15 @@ public: } }; - /*! * A wrapper around a Boost Iterator for iterating over ranges of values. * - * The methods of this class tell the associated (parent) \c ConfigTree object when - * a setting has been parsed. + * The methods of this class tell the associated (parent) \c ConfigTree + * object when a setting has been parsed. */ - template<typename ValueType> + template <typename ValueType> class ValueIterator - : public std::iterator<std::input_iterator_tag, ValueType> + : public std::iterator<std::input_iterator_tag, ValueType> { public: using Iterator = boost::property_tree::ptree::const_assoc_iterator; @@ -185,15 +197,18 @@ public: explicit ValueIterator(Iterator const& it, std::string const& root, ConfigTree const& parent) : it_(it), tagname_(root), parent_(parent) - {} + { + } - ValueIterator<ValueType>& operator++() { + ValueIterator<ValueType>& operator++() + { ++it_; has_incremented_ = true; return *this; } - ValueType operator*() { + ValueType operator*() + { // if this iterator has been incremented since the last dereference, // tell the parent_ instance that a setting now has been parsed. if (has_incremented_) @@ -205,11 +220,13 @@ public: .getValue<ValueType>(); } - bool operator==(ValueIterator<ValueType> const& other) const { + bool operator==(ValueIterator<ValueType> const& other) const + { return it_ == other.it_; } - bool operator!=(ValueIterator<ValueType> const& other) const { + bool operator!=(ValueIterator<ValueType> const& other) const + { return it_ != other.it_; } @@ -242,12 +259,12 @@ public: * \param error_cb callback function to be called on error. * \param warning_cb callback function to be called on warning. * - * The callback functions must be valid callable functions, i.e. not nullptr's. - * They are configurable in order to make unit tests of this class easier. - * They should not be provided in production code! + * The callback functions must be valid callable functions, i.e. not + * nullptr's. They are configurable in order to make unit tests of this + * class easier. They should not be provided in production code! * - * Defaults are strict: By default, both callbacks are set to the same function, - * i.e., warnings will also result in program abortion! + * Defaults are strict: By default, both callbacks are set to the same + * function, i.e., warnings will also result in program abortion! */ explicit ConfigTree(PTree const& tree, std::string filename, @@ -259,21 +276,21 @@ public: * Doing so would lead to a dangling reference \c tree_ and to program * crash. */ - explicit ConfigTree(PTree&&, std::string const&, - Callback const&, Callback const&) = delete; + explicit ConfigTree(PTree&&, std::string const&, Callback const&, + Callback const&) = delete; //! copying is not compatible with the semantics of this class ConfigTree(ConfigTree const&) = delete; - //! After being moved from, \c other is in an undefined state and must not be - //! used anymore! - ConfigTree(ConfigTree && other); + //! After being moved from, \c other is in an undefined state and must not + //! be used anymore! + ConfigTree(ConfigTree&& other); //! copying is not compatible with the semantics of this class ConfigTree& operator=(ConfigTree const&) = delete; - //! After being moved from, \c other is in an undefined state and must not be - //! used anymore! + //! After being moved from, \c other is in an undefined state and must not + //! be used anymore! ConfigTree& operator=(ConfigTree&& other); //! Used to get the project file name. @@ -290,8 +307,8 @@ public: * * \pre \c param must not have been read before from this ConfigTree. */ - template<typename T> T - getConfigParameter(std::string const& param) const; + template <typename T> + T getConfigParameter(std::string const& param) const; /*! Get parameter \c param of type \c T from the configuration tree or the * \c default_value. @@ -302,39 +319,45 @@ public: * * \pre \c param must not have been read before from this ConfigTree. */ - template<typename T> T - getConfigParameter(std::string const& param, T const& default_value) const; + template <typename T> + T getConfigParameter(std::string const& param, + T const& default_value) const; - /*! Get parameter \c param of type \c T from the configuration tree if present + /*! Get parameter \c param of type \c T from the configuration tree if + * present * - * This method has a similar behaviour as getConfigParameter(std::string const&) except - * no errors are raised. Rather it can be told from the return value if the - * parameter could be read. + * This method has a similar behaviour as getConfigParameter(std::string + * const&) except no errors are raised. Rather it can be told from the + * return value if the parameter could be read. * * \pre \c param must not have been read before from this ConfigTree. */ template <typename T> std::optional<T> getConfigParameterOptional(std::string const& param) const; - /*! Fetches all parameters with name \c param from the current level of the tree. + /*! Fetches all parameters with name \c param from the current level of the + * tree. * * The return value is suitable to be used with range-base for-loops. * * \pre \c param must not have been read before from this ConfigTree. */ - template<typename T> Range<ValueIterator<T> > - getConfigParameterList(std::string const& param) const; + template <typename T> + Range<ValueIterator<T>> getConfigParameterList( + std::string const& param) const; //!\} /*! \name Methods for accessing parameters that have attributes * - * The <tt>getConfigParameter...()</tt> methods in this group---note: they do not have template - * parameters---check that the queried parameters do not have any children (apart from XML - * attributes); if they do, error() is called. + * The <tt>getConfigParameter...()</tt> methods in this group---note: they + * do not have template parameters---check that the queried parameters do + * not have any children (apart from XML attributes); if they do, error() is + * called. * - * The support for parameters with attributes is limited in the sense that it is not - * possible to peek/check them. However, such functionality can easily be added on demand. + * The support for parameters with attributes is limited in the sense that + * it is not possible to peek/check them. However, such functionality can + * easily be added on demand. */ //!\{ @@ -355,14 +378,15 @@ public: std::optional<ConfigTree> getConfigParameterOptional( std::string const& root) const; - /*! Fetches all parameters with name \c param from the current level of the tree. + /*! Fetches all parameters with name \c param from the current level of the + * tree. * * The return value is suitable to be used with range-base for-loops. * * \pre \c param must not have been read before from this ConfigTree. */ - Range<ParameterIterator> - getConfigParameterList(std::string const& param) const; + Range<ParameterIterator> getConfigParameterList( + std::string const& param) const; /*! Get the plain data contained in the current level of the tree. * @@ -370,8 +394,8 @@ public: * * \pre The data must not have been read before. */ - template<typename T> T - getValue() const; + template <typename T> + T getValue() const; /*! Get XML attribute \c attr of type \c T for the current parameter. * @@ -379,8 +403,8 @@ public: * * \pre \c attr must not have been read before from the current parameter. */ - template<typename T> T - getConfigAttribute(std::string const& attr) const; + template <typename T> + T getConfigAttribute(std::string const& attr) const; /*! Get XML attribute \c attr of type \c T for the current parameter or the * \c default_value. @@ -410,35 +434,38 @@ public: /*! \name Methods for peeking and checking parameters * - * To be used in builder/factory functions: E.g., one can peek a parameter denoting - * the type of an object to generate in the builder, and check the type parameter in - * the constructor of the generated object. + * To be used in builder/factory functions: E.g., one can peek a parameter + * denoting the type of an object to generate in the builder, and check the + * type parameter in the constructor of the generated object. */ //!\{ /*! Peek at a parameter \c param of type \c T from the configuration tree. * - * This method is an exception to the single-read rule. It is meant to be used to - * tell from a ConfigTree instance where to pass that instance on for further processing. + * This method is an exception to the single-read rule. It is meant to be + * used to tell from a ConfigTree instance where to pass that instance on + * for further processing. * - * But in order that the requested parameter counts as "completely parsed", it has to be - * read through some other method, too. + * But in order that the requested parameter counts as "completely parsed", + * it has to be read through some other method, too. * - * Return value and error behaviour are the same as for getConfigParameter<T>(std::string const&). + * Return value and error behaviour are the same as for + * getConfigParameter<T>(std::string const&). */ - template<typename T> T - peekConfigParameter(std::string const& param) const; + template <typename T> + T peekConfigParameter(std::string const& param) const; /*! Assert that \c param has the given \c value. * - * Convenience method combining getConfigParameter(std::string const&) with a check. + * Convenience method combining getConfigParameter(std::string const&) with + * a check. */ - template<typename T> void - checkConfigParameter(std::string const& param, T const& value) const; + template <typename T> + void checkConfigParameter(std::string const& param, T const& value) const; //! Make checkConfigParameter() work for string literals. - template<typename Ch> void - checkConfigParameter(std::string const& param, Ch const* value) const; + template <typename Ch> + void checkConfigParameter(std::string const& param, Ch const* value) const; //!\} @@ -452,8 +479,7 @@ public: * * \pre \c root must not have been read before from this ConfigTree. */ - ConfigTree - getConfigSubtree(std::string const& root) const; + ConfigTree getConfigSubtree(std::string const& root) const; /*! Get the subtree rooted at \c root if present * @@ -462,14 +488,14 @@ public: std::optional<ConfigTree> getConfigSubtreeOptional( std::string const& root) const; - /*! Get all subtrees that have a root \c root from the current level of the tree. + /*! Get all subtrees that have a root \c root from the current level of the + * tree. * * The return value is suitable to be used with range-base for-loops. * * \pre \c root must not have been read before from this ConfigTree. */ - Range<SubtreeIterator> - getConfigSubtreeList(std::string const& root) const; + Range<SubtreeIterator> getConfigSubtreeList(std::string const& root) const; //!\} @@ -485,7 +511,8 @@ public: */ void ignoreConfigParameter(std::string const& param) const; - /*! Tell this instance to ignore all parameters \c param on the current level of the tree. + /*! Tell this instance to ignore all parameters \c param on the current + * level of the tree. * * This method is used to avoid warning messages. * @@ -503,10 +530,9 @@ public: //!\} - //! The destructor performs the check if all nodes at the current level of the tree - //! have been read. - //! Errors raised by the check are swallowed. Use assertNoSwallowedErrors() - //! manually to check for those. + //! The destructor performs the check if all nodes at the current level of + //! the tree have been read. Errors raised by the check are swallowed. Use + //! assertNoSwallowedErrors() manually to check for those. ~ConfigTree(); //! Default error callback function @@ -542,11 +568,13 @@ private: //! Used to indicate if dealing with XML tags or XML attributes enum class Attr : bool { - TAG = false, ATTR = true + TAG = false, + ATTR = true }; //! Used for wrapping a subtree - explicit ConfigTree(PTree const& tree, ConfigTree const& parent, std::string const& root); + explicit ConfigTree(PTree const& tree, ConfigTree const& parent, + std::string const& root); /*! Called if an error occurs. Will call the error callback. * @@ -574,9 +602,10 @@ private: * * This method asserts that a key is read always with the same type. * - * \c param peek_only if true, do not change the read-count of the given key. + * \c param peek_only if true, do not change the read-count of the given + * key. */ - template<typename T> + template <typename T> CountType& markVisited(std::string const& key, Attr const is_attr, bool peek_only) const; @@ -584,22 +613,24 @@ private: * * This method asserts that a key is read always with the same type. * - * \c param peek_only if true, do not change the read-count of the given key. + * \c param peek_only if true, do not change the read-count of the given + * key. */ CountType& markVisited(std::string const& key, Attr const is_attr, bool const peek_only) const; - //! Used in the destructor to compute the difference between number of reads of a parameter - //! and the number of times it exists in the ConfigTree + //! Used in the destructor to compute the difference between number of reads + //! of a parameter and the number of times it exists in the ConfigTree void markVisitedDecrement(Attr const is_attr, std::string const& key) const; //! Checks if this tree has any children. bool hasChildren() const; - /*! Checks if the top level of this tree has been read entirely (and not too often). + /*! Checks if the top level of this tree has been read entirely (and not too + * often). * - * \post This method also invalidates the instance, i.e., afterwards it must not - * be used anymore! + * \post This method also invalidates the instance, i.e., afterwards it must + * not be used anymore! */ void checkAndInvalidate(); @@ -618,8 +649,8 @@ private: //! A pair (is attribute, tag/attribute name). using KeyType = std::pair<Attr, std::string>; - //! A map KeyType -> (count, type) keeping track which parameters have been read - //! how often and which datatype they have. + //! A map KeyType -> (count, type) keeping track which parameters have been + //! read how often and which datatype they have. //! //! This member will be written to when reading from the config tree. //! Therefore it has to be mutable in order to be able to read from @@ -627,7 +658,8 @@ private: //! temporaries. mutable std::map<KeyType, CountType> visited_params_; - //! Indicates if the plain data contained in this tree has already been read. + //! Indicates if the plain data contained in this tree has already been + //! read. mutable bool have_read_data_ = false; Callback onerror_; //!< Custom error callback. diff --git a/BaseLib/DateTools.h b/BaseLib/DateTools.h index 6eee07616c1..0b50bb3db3e 100644 --- a/BaseLib/DateTools.h +++ b/BaseLib/DateTools.h @@ -19,7 +19,6 @@ namespace BaseLib { - /** * Converts three integers representing a date into a double. * Note: It is not really checked if the date actually makes sense. @@ -46,15 +45,16 @@ std::string date2string(double ddate); * \param s String containing the date, the expected format is "dd.mm.yyyy". * \return A number representing the date as dd.mm.yyyy. */ -int strDate2int(const std::string &s); +int strDate2int(const std::string& s); /** * Converts a string containing a date into a double. * Note: It is not really checked if the date actually makes sense. - * \param s String containing the date, the expected format is conform to the xml date type, i.e. "yyyy-mm-dd". - * \return A number representing the date as yyyymmdd. + * \param s String containing the date, the expected format is conform to the + * xml date type, i.e. "yyyy-mm-dd". \return A number representing the date as + * yyyymmdd. */ -int xmlDate2int(const std::string &s); +int xmlDate2int(const std::string& s); /** * Formats the given time point according to RFC 3339 (cf. man-page of the unix @@ -65,4 +65,4 @@ int xmlDate2int(const std::string &s); std::string formatDate( std::chrono::time_point<std::chrono::system_clock> const& time); -} // namespace BaseLib +} // namespace BaseLib diff --git a/BaseLib/Error.h b/BaseLib/Error.h index 2800921e315..c0875cdeff2 100644 --- a/BaseLib/Error.h +++ b/BaseLib/Error.h @@ -11,6 +11,7 @@ #pragma once #include <cstdlib> + #include "Logging.h" #ifdef OGS_FATAL_ABORT @@ -29,4 +30,3 @@ throw std::runtime_error(fmt::format(__VA_ARGS__)); \ } #endif // OGS_FATAL_ABORT - diff --git a/BaseLib/ExportSymbol.h b/BaseLib/ExportSymbol.h index 15f077510d7..7c0a9520143 100644 --- a/BaseLib/ExportSymbol.h +++ b/BaseLib/ExportSymbol.h @@ -11,11 +11,9 @@ #pragma once #ifndef OGS_EXPORT_SYMBOL -# if defined(WIN32) || defined(_WIN32) -# define OGS_EXPORT_SYMBOL __declspec(dllexport) -# else -# define OGS_EXPORT_SYMBOL __attribute__((visibility("default"))) -# endif +#if defined(WIN32) || defined(_WIN32) +#define OGS_EXPORT_SYMBOL __declspec(dllexport) +#else +#define OGS_EXPORT_SYMBOL __attribute__((visibility("default"))) +#endif #endif // defined(OGS_EXPORT_SYMBOL) - - diff --git a/BaseLib/FileTools.h b/BaseLib/FileTools.h index acbdf546fb1..8f43f28b719 100644 --- a/BaseLib/FileTools.h +++ b/BaseLib/FileTools.h @@ -27,7 +27,7 @@ namespace BaseLib * * \param strFilename the file name */ -bool IsFileExisting(const std::string &strFilename); +bool IsFileExisting(const std::string& strFilename); /** * Returns the begin and end position of the string enclosed in open_char and @@ -54,7 +54,8 @@ std::string constructFormattedFileName(std::string const& format_specification, * \param out output stream, have to be opened in binary mode * \param val value */ -template <typename T> void writeValueBinary(std::ostream &out, T const& val) +template <typename T> +void writeValueBinary(std::ostream& out, T const& val) { out.write(reinterpret_cast<const char*>(&val), sizeof(T)); } @@ -79,7 +80,6 @@ T swapEndianness(T const& v) double swapEndianness(double const& v); - template <typename T> T readBinaryValue(std::istream& in) { @@ -92,7 +92,8 @@ template <typename T> std::vector<T> readBinaryArray(std::string const& filename, std::size_t const n) { std::ifstream in(filename.c_str()); - if (!in) { + if (!in) + { ERR("readBinaryArray(): Error while reading from file '{:s}'.", filename); ERR("Could not open file '{:s}' for input.", filename); @@ -158,8 +159,8 @@ bool hasFileExtension(std::string const& extension, * Checks if file_name already contains a qualified path and if not copies the * path from source. */ -std::string copyPathToFileName(const std::string &file_name, - const std::string &source); +std::string copyPathToFileName(const std::string& file_name, + const std::string& source); /** Returns a string with file extension as found by getFileExtension() * dropped. diff --git a/BaseLib/Histogram.h b/BaseLib/Histogram.h index 8707e6f027a..ff7872643e6 100644 --- a/BaseLib/Histogram.h +++ b/BaseLib/Histogram.h @@ -57,8 +57,8 @@ public: /** Creates histogram from \c std::vector. * \param data Input vector. * \param nr_bins Number of bins in histogram. - * \param computeHistogram Compute histogram if set. If not set user must call - * \c update() before accessing data. + * \param computeHistogram Compute histogram if set. If not set user must + * call \c update() before accessing data. */ explicit Histogram(std::vector<T> data, const unsigned int nr_bins = 16, const bool computeHistogram = true) @@ -115,8 +115,7 @@ public: const T& getMaximum() const { return max_; } const T& getBinWidth() const { return bin_width_; } - void - prettyPrint(std::ostream& os, const unsigned int line_width = 16) const + void prettyPrint(std::ostream& os, const unsigned int line_width = 16) const { const std::size_t count_max = *std::max_element(histogram_.begin(), histogram_.end()); @@ -136,32 +135,34 @@ public: } } - int write(std::string const& file_name, std::string const& data_set_name, std::string const& param_name) const + int write(std::string const& file_name, std::string const& data_set_name, + std::string const& param_name) const { if (file_name.empty()) { - ERR ("No file name specified."); + ERR("No file name specified."); return 1; } - std::ofstream out (file_name); + std::ofstream out(file_name); if (!out) { ERR("Error writing histogram: Could not open file."); return 1; } - out << "# Histogram for parameter " << param_name << " of data set " << data_set_name << "\n"; + out << "# Histogram for parameter " << param_name << " of data set " + << data_set_name << "\n"; std::size_t const n_bins = this->getNumberOfBins(); std::vector<std::size_t> const& bin_cnts(this->getBinCounts()); - double const min (this->getMinimum()); - double const bin_width (this->getBinWidth()); + double const min(this->getMinimum()); + double const bin_width(this->getBinWidth()); for (std::size_t k(0); k < n_bins; k++) { out << min + k * bin_width << " " << bin_cnts[k] << "\n"; } - out.close (); + out.close(); return 0; } @@ -199,14 +200,12 @@ private: * number of bins, minimum, maximum, bin0 count, ..., binN-1 count. */ template <typename T> -std::ostream& -operator<<(std::ostream& os, const Histogram<T>& h) +std::ostream& operator<<(std::ostream& os, const Histogram<T>& h) { - os << h.getNumberOfBins() << " " - << h.getMinimum() << " " - << h.getMaximum() << " "; + os << h.getNumberOfBins() << " " << h.getMinimum() << " " << h.getMaximum() + << " "; std::copy(h.getBinCounts().begin(), h.getBinCounts().end(), std::ostream_iterator<T>(os, " ")); return os << std::endl; } -} // namespace BaseLib +} // namespace BaseLib diff --git a/BaseLib/MemWatch.h b/BaseLib/MemWatch.h index 03af4014854..67144e7f14e 100644 --- a/BaseLib/MemWatch.h +++ b/BaseLib/MemWatch.h @@ -14,15 +14,16 @@ #pragma once -namespace BaseLib { - -class MemWatch { +namespace BaseLib +{ +class MemWatch +{ public: - MemWatch (); - unsigned long getVirtMemUsage (); + MemWatch(); + unsigned long getVirtMemUsage(); private: - unsigned updateMemUsage (); + unsigned updateMemUsage(); unsigned long vmem_size_ = 0; }; diff --git a/BaseLib/Stream.h b/BaseLib/Stream.h index 05534d298d0..b2de204cd44 100644 --- a/BaseLib/Stream.h +++ b/BaseLib/Stream.h @@ -19,8 +19,9 @@ #include <ostream> #include <vector> -template<typename T> -std::ostream &operator <<(std::ostream &os, const std::vector<T> &v) { +template <typename T> +std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) +{ std::copy(v.begin(), v.end(), std::ostream_iterator<T>(os, " ")); os << "\n"; return os; diff --git a/BaseLib/StringTools.h b/BaseLib/StringTools.h index bd8b95d38ef..89aa2b25643 100644 --- a/BaseLib/StringTools.h +++ b/BaseLib/StringTools.h @@ -14,12 +14,13 @@ #pragma once -#include <string> #include <list> #include <sstream> +#include <string> #include <vector> -namespace BaseLib { +namespace BaseLib +{ /** * Splits a string into a vector of strings. This method only works for string * separation recognised by the std::stringstream iterator such as ' ' or @@ -35,7 +36,7 @@ std::vector<std::string> splitString(std::string const& str); * \param delim Character indicating that the string should be split * \return List of strings */ -std::list<std::string> splitString(const std::string &str, char delim); +std::list<std::string> splitString(const std::string& str, char delim); /** * Replaces a substring with another in a string @@ -44,7 +45,9 @@ std::list<std::string> splitString(const std::string &str, char delim); * \param stringToReplace Search and replace in this string * \return The modified string */ -std::string replaceString(const std::string &searchString, const std::string &replaceString, std::string stringToReplace); +std::string replaceString(const std::string& searchString, + const std::string& replaceString, + std::string stringToReplace); /** * Converts a string into a number (double, float, int, ...) @@ -52,25 +55,26 @@ std::string replaceString(const std::string &searchString, const std::string &re * \param str string to be converted * \return the number */ -template<typename T> T str2number (const std::string &str) +template <typename T> +T str2number(const std::string& str) { - std::stringstream strs (str, std::stringstream::in | std::stringstream::out); + std::stringstream strs(str, std::stringstream::in | std::stringstream::out); T v; strs >> v; return v; } /** - * Strip whitespace (or other characters) from the beginning and end of a string. - * Equivalent functionality to Qt::QString::trim(). + * Strip whitespace (or other characters) from the beginning and end of a + * string. Equivalent functionality to Qt::QString::trim(). */ -void trim(std::string &str, char ch=' '); +void trim(std::string& str, char ch = ' '); /** * Removes multiple whitespaces (or other characters) from within a string. * Equivalent functionality to Qt::QString::simplify(). */ -void simplify(std::string &str); +void simplify(std::string& str); //! Returns a random string of the given length containing just a-z,A-Z,0-9 std::string randomString(std::size_t length); @@ -78,4 +82,4 @@ std::string randomString(std::size_t length); //! Append '-' and a number such that the name is unique. std::string getUniqueName(std::vector<std::string> const& existing_names, std::string const& input_name); -} // end namespace BaseLib +} // end namespace BaseLib diff --git a/BaseLib/Subdivision.h b/BaseLib/Subdivision.h index a1d08438ee3..19ff82456a9 100644 --- a/BaseLib/Subdivision.h +++ b/BaseLib/Subdivision.h @@ -14,7 +14,6 @@ namespace BaseLib { - /** * Interface class for subdivision operators */ @@ -74,11 +73,10 @@ public: * @param max_dL maximum cell length * @param multiplier multiplier to cell length */ - GradualSubdivision( - const double L, - const double dL0, - const double max_dL, - const double multiplier); + GradualSubdivision(const double L, + const double dL0, + const double max_dL, + const double multiplier); /// Returns a vector of subdivided points std::vector<double> operator()() const override; diff --git a/BaseLib/TCLAPCustomOutput.h b/BaseLib/TCLAPCustomOutput.h index fd42cdc33ec..ccd880a89b7 100644 --- a/BaseLib/TCLAPCustomOutput.h +++ b/BaseLib/TCLAPCustomOutput.h @@ -9,21 +9,20 @@ #pragma once -#include <string> -#include <vector> -#include <list> -#include <iosfwd> -#include <algorithm> - +#include <tclap/Arg.h> #include <tclap/CmdLineInterface.h> #include <tclap/CmdLineOutput.h> #include <tclap/StdOutput.h> #include <tclap/XorHandler.h> -#include <tclap/Arg.h> + +#include <algorithm> +#include <iosfwd> +#include <list> +#include <string> +#include <vector> namespace BaseLib { - /** * TCLAP standard output modified as follows * - Print arguments in the order of added to Command object @@ -74,7 +73,6 @@ inline void TCLAPCustomOutput::usage(TCLAP::CmdLineInterface& cmd_) longUsage_(cmd_, std::cout); std::cout << std::endl; - } inline void TCLAPCustomOutput::failure(TCLAP::CmdLineInterface& cmd_, @@ -83,7 +81,8 @@ inline void TCLAPCustomOutput::failure(TCLAP::CmdLineInterface& cmd_, std::string progName = cmd_.getProgramName(); std::cerr << "PARSE ERROR: " << e.argId() << std::endl - << " " << e.error() << std::endl << std::endl; + << " " << e.error() << std::endl + << std::endl; if (cmd_.hasHelpAndVersion()) { @@ -110,32 +109,32 @@ inline void TCLAPCustomOutput::shortUsage_(TCLAP::CmdLineInterface& cmd_, std::list<TCLAP::Arg*> argList = cmd_.getArgList(); std::string progName = cmd_.getProgramName(); TCLAP::XorHandler xorHandler = cmd_.getXorHandler(); - std::vector< std::vector<TCLAP::Arg*> > xorList = xorHandler.getXorList(); + std::vector<std::vector<TCLAP::Arg*>> xorList = xorHandler.getXorList(); std::string s = progName + " "; // first the xor - for ( int i = 0; static_cast<unsigned int>(i) < xorList.size(); i++ ) + for (int i = 0; static_cast<unsigned int>(i) < xorList.size(); i++) + { + s += " {"; + for (TCLAP::ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); + it++) { - s += " {"; - for (TCLAP::ArgVectorIterator it = xorList[i].begin(); - it != xorList[i].end(); - it++) - { - s += (*it)->shortID() + "|"; - } - - s[s.length()-1] = '}'; + s += (*it)->shortID() + "|"; } + s[s.length() - 1] = '}'; + } + // then the rest - for (auto it = argList.rbegin(); it != argList.rend(); ++it) - { // here modified - if (!xorHandler.contains((*it))) - { - s += " " + (*it)->shortID(); - } + for (auto it = argList.rbegin(); it != argList.rend(); ++it) + { // here modified + if (!xorHandler.contains((*it))) + { + s += " " + (*it)->shortID(); } + } // if the program name is too long, then adjust the second line offset int secondLineOffset = static_cast<int>(progName.length()) + 2; @@ -144,7 +143,7 @@ inline void TCLAPCustomOutput::shortUsage_(TCLAP::CmdLineInterface& cmd_, secondLineOffset = static_cast<int>(75 / 2); } - spacePrint( os, s, 75, 3, secondLineOffset ); + spacePrint(os, s, 75, 3, secondLineOffset); } inline void TCLAPCustomOutput::longUsage_(TCLAP::CmdLineInterface& cmd_, @@ -153,40 +152,40 @@ inline void TCLAPCustomOutput::longUsage_(TCLAP::CmdLineInterface& cmd_, std::list<TCLAP::Arg*> argList = cmd_.getArgList(); std::string message = cmd_.getMessage(); TCLAP::XorHandler xorHandler = cmd_.getXorHandler(); - std::vector< std::vector<TCLAP::Arg*> > xorList = xorHandler.getXorList(); + std::vector<std::vector<TCLAP::Arg*>> xorList = xorHandler.getXorList(); // first the xor - for ( int i = 0; static_cast<unsigned int>(i) < xorList.size(); i++ ) + for (int i = 0; static_cast<unsigned int>(i) < xorList.size(); i++) + { + for (TCLAP::ArgVectorIterator it = xorList[i].begin(); + it != xorList[i].end(); + it++) { - for ( TCLAP::ArgVectorIterator it = xorList[i].begin(); - it != xorList[i].end(); - it++ ) - { - this->spacePrint( os, (*it)->longID(), 75, 3, 3 ); - spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); - - if (it + 1 != xorList[i].end()) - { - spacePrint(os, "-- OR --", 75, 9, 0); - } - } - os << std::endl << std::endl; - } + this->spacePrint(os, (*it)->longID(), 75, 3, 3); + spacePrint(os, (*it)->getDescription(), 75, 5, 0); - // then the rest - for (auto it = argList.rbegin(); it != argList.rend(); it++) - { // here modified - if (!xorHandler.contains((*it))) + if (it + 1 != xorList[i].end()) { - spacePrint( os, (*it)->longID(), 75, 3, 3 ); - spacePrint( os, (*it)->getDescription(), 75, 5, 0 ); - os << std::endl; + spacePrint(os, "-- OR --", 75, 9, 0); } } + os << std::endl << std::endl; + } + + // then the rest + for (auto it = argList.rbegin(); it != argList.rend(); it++) + { // here modified + if (!xorHandler.contains((*it))) + { + spacePrint(os, (*it)->longID(), 75, 3, 3); + spacePrint(os, (*it)->getDescription(), 75, 5, 0); + os << std::endl; + } + } os << std::endl; - spacePrint( os, message, 75, 3, 0 ); + spacePrint(os, message, 75, 3, 0); } -} //namespace BaseLib +} // namespace BaseLib diff --git a/BaseLib/quicksort.h b/BaseLib/quicksort.h index 662c9a37e6e..f3e96e7cd45 100644 --- a/BaseLib/quicksort.h +++ b/BaseLib/quicksort.h @@ -30,9 +30,9 @@ void quicksort(It1 first1, It1 last1, It2 first2, Comparator compare) std::vector<std::pair<T1, T2>> data; data.reserve(std::distance(first1, last1)); - std::transform( - first1, last1, first2, std::back_inserter(data), - [](T1 const& t1, T2 const& t2) { return std::make_pair(t1, t2); }); + std::transform(first1, last1, first2, std::back_inserter(data), + [](T1 const& t1, T2 const& t2) + { return std::make_pair(t1, t2); }); // Sort data using first element of the pair. std::sort(begin(data), end(data), compare); @@ -55,9 +55,8 @@ void quicksort(It1 first1, It1 last1, It2 first2) using T2 = typename std::iterator_traits<It2>::value_type; quicksort(first1, last1, first2, - [](std::pair<T1, T2> const& a, std::pair<T1, T2> const& b) { - return a.first < b.first; - }); + [](std::pair<T1, T2> const& a, std::pair<T1, T2> const& b) + { return a.first < b.first; }); } /// @pre {end<=array.size() and perm.size()==array.size()} @@ -70,45 +69,43 @@ void quicksort(T1* array, std::size_t beg, std::size_t end, T2* perm) } template <typename T1, typename T2 = std::size_t> -void quicksort(std::vector<T1>& array, std::size_t beg, std::size_t end, std::vector<T2>& perm) +void quicksort(std::vector<T1>& array, std::size_t beg, std::size_t end, + std::vector<T2>& perm) { - assert (beg<=end); - assert (end<=array.size()); - assert (perm.size()==array.size()); + assert(beg <= end); + assert(end <= array.size()); + assert(perm.size() == array.size()); quicksort(array.data(), beg, end, perm.data()); } template <typename T1, typename T2 = std::size_t> -void quicksort(std::vector<T1*>& array, std::size_t beg, std::size_t end, std::vector<T2>& perm) +void quicksort(std::vector<T1*>& array, std::size_t beg, std::size_t end, + std::vector<T2>& perm) { - assert (beg<=end); - assert (end<=array.size()); - assert (perm.size()==array.size()); + assert(beg <= end); + assert(end <= array.size()); + assert(perm.size() == array.size()); // Zip input arrays. std::vector<std::pair<T1*, T2>> data; - data.reserve(end-beg); - std::transform(array.begin()+beg, array.begin()+end, perm.begin()+beg, - std::back_inserter(data), - [](T1* const& t1, T2 const& t2) - { - return std::make_pair(t1, t2); - }); + data.reserve(end - beg); + std::transform(array.begin() + beg, array.begin() + end, perm.begin() + beg, + std::back_inserter(data), + [](T1* const& t1, T2 const& t2) + { return std::make_pair(t1, t2); }); // Sort data using first element of the pair. std::sort(data.begin(), data.end(), - [](std::pair<T1*, T2> const& a, std::pair<T1*, T2> const& b) - { - return (*a.first < *b.first); - }); + [](std::pair<T1*, T2> const& a, std::pair<T1*, T2> const& b) + { return (*a.first < *b.first); }); // Unzip sorted data. for (std::size_t i = 0; i < data.size(); i++) { - array[beg+i] = data[i].first; - perm[beg+i] = data[i].second; + array[beg + i] = data[i].first; + perm[beg + i] = data[i].second; } } -} // end namespace BaseLib +} // end namespace BaseLib -- GitLab