diff --git a/include/emp/base/notify.hpp b/include/emp/base/notify.hpp index e7bcb48874..6ab969f6b6 100644 --- a/include/emp/base/notify.hpp +++ b/include/emp/base/notify.hpp @@ -334,7 +334,7 @@ namespace notify { /// Send out a notification of an ERROR. template static bool Error(Ts... args) { - bool success = Notify(Type::ERROR, std::forward(args)...); + bool success = Notify(Type::ERROR, std::forward(args)...); if (!success) { #ifdef NDEBUG Exit(1); diff --git a/include/emp/bits/Bits.hpp b/include/emp/bits/Bits.hpp index 3f2b9d57ca..edb8b787d5 100644 --- a/include/emp/bits/Bits.hpp +++ b/include/emp/bits/Bits.hpp @@ -9,7 +9,7 @@ * * The Bits template allows the user to recreate the functionality of std::vector, * array, std::bitset, and other such bit-handling classes. - * + * * This class stores an arbitrary number of bits in a set of "fields" (typically 32 bits or 64 * bits per field, depending on which should be faster.) Individual bits can be extracted, * -or- bitwise logic (including more complex bit magic) can be used on the groups of bits. @@ -25,13 +25,13 @@ * StaticBitValue : Like BitValue, but max size and fixed memory. * BitArray : A replacement for std::array (index 0 is on left) * BitSet : A replacement for std::bitset (index 0 is on right) - * + * * In the case of replacements, the aim was for identical functionality, but many additional * features, especially associated with bitwise logic operations. - * + * * @note Compile with -O3 and -msse4.2 for fast bit counting. * - * + * * @todo Most of the operators don't check to make sure that both Bit groups are the same size. * We should create versions (Intersection() and Union()?) that adjust sizes if needed. * @todo Do small BitVector optimization. Currently we have number of bits (8 bytes) and a @@ -76,7 +76,7 @@ namespace emp { /// @brief A flexible base template to handle BitVector, BitArray, BitSet, & other combinations. /// @tparam DATA_T How is this Bits object allowed to change size? - /// @tparam ZERO_LEFT Should the index of zero be the left-most bit? (right-most if false) + /// @tparam ZERO_LEFT Should the index of zero be the left-most bit? (right-most if false) template class Bits { using this_t = Bits; @@ -160,7 +160,7 @@ namespace emp { public: /// @brief Default constructor; will build the default number of bits (often 0, but not always) - /// @param init_val Initial value of all default bits. + /// @param init_val Initial value of all default bits. Bits(bool init_val=0) { if (init_val) SetAll(); else Clear(); } /// @brief Build a new Bits with specified bit count and initialization (default 0) diff --git a/include/emp/bits/Bits_Data.hpp b/include/emp/bits/Bits_Data.hpp index 0c61068998..d109c3e6da 100644 --- a/include/emp/bits/Bits_Data.hpp +++ b/include/emp/bits/Bits_Data.hpp @@ -183,7 +183,7 @@ namespace emp { Bits_Data_Mem_Static_Base & operator=(Bits_Data_Mem_Static_Base &&) = default; // --- Helper functions -- - + [[nodiscard]] Ptr FieldPtr() { return bits.data(); } [[nodiscard]] Ptr FieldPtr() const { return bits.data(); } @@ -191,7 +191,7 @@ namespace emp { const size_t old_num_fields = BASE_T::NumFields(); BASE_T::SetSize(new_size); if (preserve_data && BASE_T::NumEndBits()) { - bits[BASE_T::LastField()] &= BASE_T::EndMask(); + bits[BASE_T::LastField()] &= BASE_T::EndMask(); for (size_t id = BASE_T::NumFields(); id < old_num_fields; ++id) bits[id] = 0; } } @@ -208,7 +208,7 @@ namespace emp { } }; - + template using Bits_Data_Mem_Static = Bits_Data_Mem_Static_Base< Bits_Data_Size_Var, CAPACITY >; @@ -373,7 +373,7 @@ namespace emp { base_t::SetSize(new_size); if (preserve_data) { - // Clear any new (or previously unused) fields. + // Clear any new (or previously unused) fields. for (size_t i = num_old_fields; i < num_new_fields; ++i) bits[i] = 0; // Clear out any extra end bits. diff --git a/include/emp/bits/bitset_utils.hpp b/include/emp/bits/bitset_utils.hpp index ddddd0dadd..c9b0d3818a 100644 --- a/include/emp/bits/bitset_utils.hpp +++ b/include/emp/bits/bitset_utils.hpp @@ -44,7 +44,7 @@ namespace emp { [[nodiscard]] static std::string BitFieldsToString(emp::Ptr bits, size_t count) { std::stringstream ss; for (size_t i = 0; i < count; ++i) { - if (i) ss << ' '; + if (i) ss << ' '; ss << BitFieldToString(bits[i]); } return ss.str(); diff --git a/include/emp/compiler/Lexer.hpp b/include/emp/compiler/Lexer.hpp index 67ecd2ea28..0e4438250e 100644 --- a/include/emp/compiler/Lexer.hpp +++ b/include/emp/compiler/Lexer.hpp @@ -6,24 +6,24 @@ * @file Lexer.hpp * @brief A general-purpose, fast lexer. * @note Status: BETA - * + * * Build a lexer that can convert input strings or streams into a series of provided tokens. - * + * * Use AddToken(name, regex) to list out the relevant tokens. * 'name' is the unique name for this token. * 'regex' is the regular expression that describes this token. * It will return a unique ID associated with this lexeme. - * + * * IgnoreToken(name, regex) uses the same arguments, but is used for tokens that * should be skipped over. - * + * * Names and IDs can be recovered later using GetTokenID(name) and GetTokenName(id). - * + * * Tokens can be retrieved either one at a time with Process(string) or Process(stream), * which will return the next (non-ignored) token, removing it from the input. - * + * * Alternatively, an entire series of tokens can be processed with Tokenize(). - * + * * Finally, GetLexeme() can be used to retrieve the lexeme from the most recent token found. */ @@ -349,7 +349,7 @@ namespace emp { } /// Turn a vector of strings into a vector of tokens. - TokenStream Tokenize(const emp::vector & str_v, + TokenStream Tokenize(const emp::vector & str_v, const std::string & name="in_string vector") const { std::stringstream ss; diff --git a/include/emp/config/FlagManager.hpp b/include/emp/config/FlagManager.hpp index 878496be2b..cdc51d95dc 100644 --- a/include/emp/config/FlagManager.hpp +++ b/include/emp/config/FlagManager.hpp @@ -6,24 +6,24 @@ * @file FlagManager.hpp * @brief This file contains tools for dealing with command-line flags (from argv and argc). * @note Status: ALPHA - * + * * The FlagManager class will take command line arguments (either in its constructor or with * the AddFlags() function) and process them appropriately. - * + * * For setup, the user must run AddOption with the function to call. Functions to call can take * zero, one, or two Strings as arguments OR they can take a vector of Strings and the range of * allowed arguments should be specified. When Process() is run, the appropriate function will * be called on each and any invalid arguments will trigger an error. - * + * * Flags are expected to begin with a '-' and non-flags are expected to NOT begin with a '-'. - * + * * If a single dash is followed by multiple characters, each will be processed independently. * So, "-abc" will be the same as "-a -b -c". - * + * * Extra command line arguments will be saves as a vector of strings called "extras" and must * be processed manually. They can be retrieved with GetExtras(). - * - * + * + * * @todo: Make variable numbers of flag arguments work. */ diff --git a/include/emp/data/DataMap.hpp b/include/emp/data/DataMap.hpp index 24369fd593..132badc8ca 100644 --- a/include/emp/data/DataMap.hpp +++ b/include/emp/data/DataMap.hpp @@ -402,7 +402,7 @@ namespace emp { /// Return a function that takes in a data map and (efficiently) returns a Datum using the /// specified name. - static auto MakeDatumAccessor(const emp::DataLayout & layout, const std::string & name) { + static auto MakeDatumAccessor(const emp::DataLayout & layout, const std::string & name) { emp_assert(layout.HasName(name), "DatumAccessor not pointing to valid name", name); return MakeDatumAccessor(layout, layout.GetID(name)); } diff --git a/include/emp/data/README.md b/include/emp/data/README.md index 2571314d7c..b851d57b7c 100644 --- a/include/emp/data/README.md +++ b/include/emp/data/README.md @@ -43,7 +43,7 @@ This directory contains a set of tools for managing more or less genetic data. * DataMapParser.hpp - A parser to take an equation based on variables in a DataLayout that will produce a lambda. If a DataMap is passed into the lambda the equation will be calculated and the result returned. - + * Trait.hpp - ? @@ -55,7 +55,7 @@ DataRow - Same interface as DataMap; refers to associated DataFrame. DataTracker - Handles all of the functionality of DataNode, DataLog, etc., but more dynamic using lambdas to deal with values as needed. - + ## To modify? diff --git a/include/emp/data/SimpleParser.hpp b/include/emp/data/SimpleParser.hpp index 0356e9b5f6..eb242fec90 100644 --- a/include/emp/data/SimpleParser.hpp +++ b/include/emp/data/SimpleParser.hpp @@ -12,7 +12,7 @@ * Allowed map types include std::map, std::unordered_map, * emp::DataMap, and (soon) derivations from emp::AnnotatedType. For standard maps, T must be * convertable to emp::Datum. - * + * * Developer TODO: * - Setup operator RegEx to be built dynamically * - Setup LVALUES as a type, and allow assignment diff --git a/include/emp/datastructs/IndexSet.hpp b/include/emp/datastructs/IndexSet.hpp index cd0b292479..24ee45275a 100644 --- a/include/emp/datastructs/IndexSet.hpp +++ b/include/emp/datastructs/IndexSet.hpp @@ -138,7 +138,7 @@ namespace emp { size_t GetEnd() const { return range_set.size() ? range_set.back().GetEnd() : 0; } - + size_t GetNumRanges() const { return range_set.size(); } /// @brief Calculate the total combined size of all ranges. diff --git a/include/emp/datastructs/QueueCache.hpp b/include/emp/datastructs/QueueCache.hpp index 55f66d98f7..16b69791c9 100644 --- a/include/emp/datastructs/QueueCache.hpp +++ b/include/emp/datastructs/QueueCache.hpp @@ -126,7 +126,7 @@ if (found != cache_map.end()) { Delete(found); } - + cache_list.emplace_front(key, val); // Put element into the cache cache_map.emplace(key, cache_list.begin()); // Add element pointer to map Shrink(); // Reduce if we are over capacity diff --git a/include/emp/datastructs/UnorderedIndexMap.hpp b/include/emp/datastructs/UnorderedIndexMap.hpp index ec2dcd5cc8..d075f9d029 100644 --- a/include/emp/datastructs/UnorderedIndexMap.hpp +++ b/include/emp/datastructs/UnorderedIndexMap.hpp @@ -79,7 +79,7 @@ namespace emp { emp_assert(num_items > 0, "UnorderedIndexMaps should not be initialized with empty weights"); for (size_t i = 0; i < num_items; i++) weights[i + num_nodes] = in_weights[i]; } - + UnorderedIndexMap(const UnorderedIndexMap &) = default; UnorderedIndexMap(UnorderedIndexMap &&) = default; ~UnorderedIndexMap() = default; diff --git a/include/emp/datastructs/ra_map.hpp b/include/emp/datastructs/ra_map.hpp index 73072a9e7f..86bff50254 100644 --- a/include/emp/datastructs/ra_map.hpp +++ b/include/emp/datastructs/ra_map.hpp @@ -6,7 +6,7 @@ * @file ra_map.hpp * @brief This file defines a Random Access Map template. * @note Status: ALPHA - * + * * A random access map allows for simple traversal by index and a guarantee that a value at a * given index will always be at that index unless any map element is deleted. This allows * storage of indices for maps with a fixed layout, resulting in easy access. @@ -131,7 +131,7 @@ namespace emp { return true; } - + size_t count(const KEY_T & key) const { return id_map.count(key); } /// Is value included? (0 or 1). /// Index into the ra_map by key. diff --git a/include/emp/hardware/VirtualCPU.hpp b/include/emp/hardware/VirtualCPU.hpp index 0b6258eb57..d2f3d52326 100644 --- a/include/emp/hardware/VirtualCPU.hpp +++ b/include/emp/hardware/VirtualCPU.hpp @@ -127,7 +127,7 @@ namespace emp{ size_t write_head; ///< Write head, signals where to copy next ///< instruction size_t cooldown_timer = 0; ///< Do not process inst if value > 0. - ///< Decrease this value instead + ///< Decrease this value instead //////// HELPER CONSTRUCTS emp::unordered_map nop_id_map;/**< NOP inst id -> Nop index (e.g., NopA -> 0, NopB -> 1, @@ -252,7 +252,7 @@ namespace emp{ /// Redirect literal ints to PushInst(size_t) overload. void PushInst(int idx) { PushInst(static_cast(idx)); } - /// Add a new instruction to the end of the genome, by the instruction's symbol/char + /// Add a new instruction to the end of the genome, by the instruction's symbol/char void PushInst(char c) { PushInst( GetInstLib()->GetIndexFromSymbol(c) ); } /// Add a new instruction to the end of the genome, by name @@ -353,7 +353,7 @@ namespace emp{ //////// HEAD MANIPULATION - + void ResetIP() { inst_ptr = 0; } ///< Move instruction pointer to beginning of the genome. void ResetRH() { read_head = 0; } ///< Move read head to beginning of the genome. void ResetWH() { write_head = 0; } ///< Move write head to beginning of the genome. diff --git a/include/emp/in_progress/SimpleParser.hpp b/include/emp/in_progress/SimpleParser.hpp index c649e4b557..d88a9f9048 100644 --- a/include/emp/in_progress/SimpleParser.hpp +++ b/include/emp/in_progress/SimpleParser.hpp @@ -6,7 +6,7 @@ * @file SimpleParser.hpp * @brief Common praser functionality with custom plugins for variables and functions. * @note Status: ALPHA - * + * * Developer TODO: * - Make ${ ... } actually work * - Setup operator RegEx to be built dynamically @@ -234,7 +234,7 @@ namespace emp { if (pos->lexeme == ",") ++pos; } ++pos; - + // Now build the function based on its argument count. value_fun_t out_fun; switch (args.size()) { diff --git a/include/emp/io/File.hpp b/include/emp/io/File.hpp index 7e2bc49707..4993583f1b 100644 --- a/include/emp/io/File.hpp +++ b/include/emp/io/File.hpp @@ -211,7 +211,7 @@ namespace emp { if constexpr ( std::is_same() ) { cur_line = fun(cur_line); } else { - fun(cur_line); + fun(cur_line); } } return *this; diff --git a/include/emp/math/Range.hpp b/include/emp/math/Range.hpp index 4c08e176ec..d5f88d2f42 100644 --- a/include/emp/math/Range.hpp +++ b/include/emp/math/Range.hpp @@ -82,7 +82,7 @@ namespace emp { lower = (MaxLimit() - shift > lower) ? (lower + shift) : MaxLimit(); } void Shift(T shift) { - if (shift > 0) ShiftUp(shift); + if (shift > 0) ShiftUp(shift); else ShiftDown(-shift); } diff --git a/include/emp/math/RangeSet.hpp b/include/emp/math/RangeSet.hpp index 04cce01538..98ed956da0 100644 --- a/include/emp/math/RangeSet.hpp +++ b/include/emp/math/RangeSet.hpp @@ -41,8 +41,8 @@ namespace emp { // } size_t _FindRange(T value) const { auto it = std::lower_bound( - range_set.begin(), - range_set.end(), + range_set.begin(), + range_set.end(), value, [](const range_t & range, T value) { return range.GetUpper() < value; } ); @@ -155,7 +155,7 @@ namespace emp { /// @return Overall end of all ranges (or min value if no ranges exist.) [[nodiscard]] T GetEnd() const { return IsEmpty() ? MinLimit() : range_set.back().Upper(); } - + [[nodiscard]] size_t GetNumRanges() const { return range_set.size(); } /// @brief Calculate the total combined size of all ranges. @@ -284,7 +284,7 @@ namespace emp { } // Otherwise insert as a new range. - else _InsertRange(start_id, in); + else _InsertRange(start_id, in); return *this; } @@ -366,7 +366,7 @@ namespace emp { range_set[start_id].SetUpper(rm_range.Lower()); return *this; } - + // Deal with beginning of removal - cut it down if needed, and move on to next range. if (rm_range.Lower() > start_range.Lower()) { start_range.Upper() = rm_range.Lower(); @@ -472,7 +472,7 @@ namespace emp { return out; } - /// @brief Check for internal errors in this RangeSet. + /// @brief Check for internal errors in this RangeSet. bool OK() const { // Check each range individually. for (const auto & range : range_set) { diff --git a/include/emp/text/EmphaticEncoding.hpp b/include/emp/text/EmphaticEncoding.hpp index cbf1e56fac..247c4a6fa0 100644 --- a/include/emp/text/EmphaticEncoding.hpp +++ b/include/emp/text/EmphaticEncoding.hpp @@ -6,7 +6,7 @@ * @file EmphaticEncoding.hpp * @brief Plugs into emp::Text, setting up inputs and output to be Emphatic encoded. * @note Status: ALPHA - * + * */ #ifndef EMP_TEXT_EMPHATICENCODING_HPP_INCLUDE @@ -64,7 +64,7 @@ namespace emp { public: EmphaticEncoding() { SetupTags(); } - ~EmphaticEncoding() = default; + ~EmphaticEncoding() = default; String GetName() const override { return "emphatic"; } emp::Ptr Clone() const override { diff --git a/include/emp/text/HTMLEncoding.hpp b/include/emp/text/HTMLEncoding.hpp index 0bc446e84c..269d0eea9b 100644 --- a/include/emp/text/HTMLEncoding.hpp +++ b/include/emp/text/HTMLEncoding.hpp @@ -6,7 +6,7 @@ * @file HTMLEncoding.hpp * @brief Plugs into emp::Text, setting up inputs and output to be HTML encoded. * @note Status: ALPHA - * + * */ #ifndef EMP_TEXT_HTMLENCODING_HPP_INCLUDE diff --git a/include/emp/text/NOTES b/include/emp/text/NOTES index 1e3a3b7764..bda76da255 100644 --- a/include/emp/text/NOTES +++ b/include/emp/text/NOTES @@ -31,7 +31,7 @@ Internal encoding (Emphatic) header - followed by header level (e.g.: header:1) link - text should redirect to provided URL (e.g.: link:https://google.com) image - followed by location of image. - + --------------------------------------- @@ -41,9 +41,9 @@ MarkBack notes: New format is .mback, which is inspired by markdown, but uses just two types of special characters for formatting: Backquotes (`) indicate a change in text STYLE Backslashes (\) indicate a special CHARACTER - + The following tags toggle a formatting STYLE. - + `*Bold!`* ``Code`` `/Italic`/ @@ -65,20 +65,20 @@ MarkBack notes: Code -- see below. `{var name=value or other_code} `?{TEST}Optional formatting -- e.g., ?{has_error}[red] or ?{important}* - + The following tags change the format for the rest of the line they are on. These should generally be the first non-whitespace on a line, but if not a newline will be assumed before them. - + `" Blockquote `% Comment that will be removed. `| Continues the previous line for other tags in this group. - + Anything with three backticks (```) before and after will be treated as code blocks. Add a `= at the beginning of a line if you don't want any special formatting on that line. - + A single or double backtick indicates that everything in between is going to be inline code. A single backtick must be followed by an alphanumeric character or whitespace, but a double backtick can be followed by anything. - + `This would be rendered as CODE` ``{This would also be code, _with_ the braces appearing}`` @@ -121,7 +121,7 @@ MarkBack notes: Now for the crazy. We can EMBED CODE as needed. - + `{var name=value or other_code} \${var_value_printed_here} `?{TEST}Optional formatting -- e.g., ?{has_error}[red] or ?{important}* diff --git a/include/emp/text/Text.hpp b/include/emp/text/Text.hpp index c2e883937d..3dcfeb0e52 100644 --- a/include/emp/text/Text.hpp +++ b/include/emp/text/Text.hpp @@ -6,11 +6,11 @@ * @file Text.hpp * @brief Functionality similar to emp::String, but tracks text formatting for easy conversion. * @note Status: ALPHA - * + * * Text should be functionally interchangable with string, but can easily convert to * HTML, Latex, RTF, or other formats that support bold, italic, super/sub-scripting, fonts, * etc. - * + * * The main Text class tracks a string of text (called simply "text") and any special styles * associated with each text position (in "style_map"). The current TextEncoding class helps * guide the conversion from one text encoding to another. @@ -28,7 +28,7 @@ * "color:NAME" * "font:NAME" * "size:POINT_SIZE" - * + * * STRUCTURAL : * "heading:1" through "heading:6" different levels of headings. * "blockquote" @@ -317,7 +317,7 @@ namespace emp { SetStyle(style, pos); } return *this; - } + } TextCharRef operator[](size_t pos) { emp_assert(pos < GetSize(), pos, GetSize()); @@ -469,7 +469,7 @@ namespace emp { Text & ClearSubscript() { return Clear("subscript"); } Text & ClearSuperscript() { return Clear("superscript"); } Text & ClearUnderline() { return Clear("underline"); } - + // Simple formatting: clear a single character from a specified format. Text & Clear(const String & style, size_t pos) { auto it = style_map.find(style); @@ -526,7 +526,7 @@ namespace emp { void TextEncoding_None::PrintDebug(std::ostream & os) const { os << "TextEncoding None."; } - + } #endif // #ifndef EMP_TEXT_TEXT_HPP_INCLUDE diff --git a/include/emp/text/TextEncoding.hpp b/include/emp/text/TextEncoding.hpp index 041c39f64b..70694706a5 100644 --- a/include/emp/text/TextEncoding.hpp +++ b/include/emp/text/TextEncoding.hpp @@ -6,7 +6,7 @@ * @file TextEncoding.hpp * @brief Plugs into emp::Text with the specification of a given encoding. * @note Status: ALPHA - * + * */ #ifndef EMP_TEXT_TEXTENCODING_HPP_INCLUDE @@ -119,7 +119,7 @@ namespace emp { new_style.id = style_set.size(); style_set.push_back(new_style); name_to_style_id[style_name] = new_style.id; - return style_set.back(); + return style_set.back(); } size_t style_id = name_to_style_id[style_name]; return style_set[style_id]; @@ -287,7 +287,7 @@ namespace emp { SetupLexer(); auto tokens = lexer.Tokenize(in.str()); String raw_text; // Place to accumulate raw text. - for (const auto & token : tokens) { + for (const auto & token : tokens) { if (token.id == text_token) raw_text += token.lexeme; else { if (raw_text.size()) Append_RawText(text, raw_text.PopAll()); diff --git a/include/emp/text/_TextCharRef.hpp b/include/emp/text/_TextCharRef.hpp index 9bfeeb1346..01ba52d29a 100644 --- a/include/emp/text/_TextCharRef.hpp +++ b/include/emp/text/_TextCharRef.hpp @@ -6,7 +6,7 @@ * @file _TextCharRef.hpp * @brief Handles a single, potentially formatted character from emp::Text. * @note Status: ALPHA - * + * */ #ifndef EMP_TEXT__TEXTCHARREF_HPP_INCLUDE @@ -73,7 +73,7 @@ namespace emp { TextCharRef & SetStyle(const String & style) { text_ref.SetStyle(style, pos); - return *this; + return *this; } TextCharRef & Bold() { return SetStyle("bold"); } TextCharRef & Code() { return SetStyle("code"); } diff --git a/include/emp/tools/MemoryFactory.hpp b/include/emp/tools/MemoryFactory.hpp index a8575989d0..f2ba5d9909 100644 --- a/include/emp/tools/MemoryFactory.hpp +++ b/include/emp/tools/MemoryFactory.hpp @@ -71,7 +71,7 @@ namespace emp { pool_size = chunk_size * pool_count; pool.NewArray(pool_size); free_ids.resize(pool_count); - std::iota(free_ids.begin(), free_ids.end(), 0); + std::iota(free_ids.begin(), free_ids.end(), 0); } void Initialize(size_t _mem_count, size_t _pool_count) { emp_assert(mem_count == 0, "Cannot (currently) re-initialize a memory factory."); @@ -168,7 +168,7 @@ namespace emp { emp_assert(it != data.free_ids.begin()+free_count); // Make sure it's there! *it = data.free_ids.back(); // Move last ID into its position. free_count--; // Eliminate old final ID (now moved). - + const size_t id_pos = id * data.mem_size; if constexpr (!is_trivial || sizeof...(ARGS) > 0) { for (size_t i = 0; i < data.mem_count; ++i) { @@ -202,7 +202,7 @@ namespace emp { return; } } - + const size_t id = ToID(in); emp_assert(!IsFreeID(id), "Trying to release ID that is already free.", id); emp_assert(IsValidID(id), "Trying to release invalid ID", id); diff --git a/include/emp/tools/StaticString.hpp b/include/emp/tools/StaticString.hpp index 0bd5c05d94..06cb0c7bc1 100644 --- a/include/emp/tools/StaticString.hpp +++ b/include/emp/tools/StaticString.hpp @@ -6,11 +6,11 @@ * @file StaticString.hpp * @brief String substitute with a fixed max character count and always in place. * @note Status: ALPHA - * + * * A fixed number of chars are reserved for the string; errors will trigger for longer attempts. * The last allocated byte stores the number of unused positions in the string; this naturally * becomes zero (the final character in a string) when all positions are used. - * + * */ #ifndef EMP_TOOLS_STATICSTRING_HPP_INCLUDE diff --git a/include/emp/tools/String.hpp b/include/emp/tools/String.hpp index 6521f90ab5..31b426a0a4 100644 --- a/include/emp/tools/String.hpp +++ b/include/emp/tools/String.hpp @@ -245,7 +245,7 @@ namespace emp { // size_t capacity() const; // void reserve(size_t new_cap); // void shrink_to_fit(); - + // ------ Classification and Comparisons ------ // Inherited functions from std::string: @@ -254,7 +254,7 @@ namespace emp { // bool ends_with(...) const noexcept; // bool contains(...) const noexcept; - [[nodiscard]] bool HasAt(const String test, size_t pos) const + [[nodiscard]] bool HasAt(const String test, size_t pos) const { return (size() < test.size()+pos) && View(pos, test.size()) == test; } [[nodiscard]] bool HasPrefix(const String & prefix) const { return starts_with(prefix); } [[nodiscard]] bool HasSuffix(const String & suffix) const { return ends_with(suffix); } @@ -451,33 +451,33 @@ namespace emp { [[nodiscard]] inline size_t FindAnyOf(T test1, Ts... tests) const; [[nodiscard]] inline size_t FindID(String target, size_t start, const Syntax & syntax=Syntax::Quotes()) const; - [[nodiscard]] size_t FindWhitespace(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindWhitespace(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(WhitespaceCharSet(), start, syntax); } - [[nodiscard]] size_t FindNonWhitespace(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindNonWhitespace(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(!WhitespaceCharSet(), start, syntax); } - [[nodiscard]] size_t FindUpperChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindUpperChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(UpperCharSet(), start, syntax); } - [[nodiscard]] size_t FindNonUpperChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindNonUpperChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(!UpperCharSet(), start, syntax); } - [[nodiscard]] size_t FindLowerChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindLowerChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(LowerCharSet(), start, syntax); } - [[nodiscard]] size_t FindNonLowerChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindNonLowerChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(!LowerCharSet(), start, syntax); } - [[nodiscard]] size_t FindLetterChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindLetterChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(LetterCharSet(), start, syntax); } - [[nodiscard]] size_t FindNonLetterChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindNonLetterChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(!LetterCharSet(), start, syntax); } - [[nodiscard]] size_t FindDigitChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindDigitChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(DigitCharSet(), start, syntax); } - [[nodiscard]] size_t FindNonDigitChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindNonDigitChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(!DigitCharSet(), start, syntax); } - [[nodiscard]] size_t FindAlphanumericChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindAlphanumericChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(AlphanumericCharSet(), start, syntax); } - [[nodiscard]] size_t FindNonAlphanumericChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindNonAlphanumericChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(!AlphanumericCharSet(), start, syntax); } - [[nodiscard]] size_t FindIDChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindIDChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(IDCharSet(), start, syntax); } - [[nodiscard]] size_t FindNonIDChar(size_t start=0, const Syntax & syntax=Syntax::None()) const + [[nodiscard]] size_t FindNonIDChar(size_t start=0, const Syntax & syntax=Syntax::None()) const { return Find(!IDCharSet(), start, syntax); } @@ -556,7 +556,7 @@ namespace emp { String delim=",", const Syntax & syntax=Syntax::Quotes() ) const; - + inline void SliceAssign( std::map & out_map, String delim=",", String assign_op="=", @@ -584,7 +584,7 @@ namespace emp { for (size_t i = 0; i < count; ++i) out += *this; return out; } - + // ------ FORMATTING ------ // Set* replaces the current string with argument OR converts the current string if no argument. @@ -654,7 +654,7 @@ namespace emp { { *this += MakeEnglishList(container); return *this;} template String & SetEnglishList(const CONTAINER_T & container) { *this = MakeEnglishList(container); return *this;} - + template String & AppendFormatted(const std::string& format, ARG_Ts... args) { return *this += MakeFormatted(format, std::forward(args)...); } template String & SetFormatted(const std::string& format, ARG_Ts... args) @@ -739,7 +739,7 @@ namespace emp { // FUNCTION DEFINITIONS // //////////////////////////////////////////////////////////////////////////// - + /// Determine if this string represents a proper number. bool String::IsNumber() const { if (!size()) return false; // If string is empty, not a number! @@ -977,7 +977,7 @@ namespace emp { } } - // Find an whole identifier (same as find, but cannot have letter, digit or '_' before or after.) + // Find an whole identifier (same as find, but cannot have letter, digit or '_' before or after.) size_t String::FindID(String target, size_t start, const Syntax & syntax) const { size_t pos = Find(target, start, syntax); @@ -1096,7 +1096,7 @@ namespace emp { template T String::PopFromLiteral(const Syntax & syntax) { - return MakeFromLiteral(PopLiteral(syntax)); + return MakeFromLiteral(PopLiteral(syntax)); } /// @brief Cut up a string based on the provided delimiter; fill them in to the provided vector. @@ -1164,7 +1164,7 @@ namespace emp { ViewSlices(result, delim, syntax); return result; } - + /// @brief Slice a string and treat each section as an assignment; place results in provided map. /// @param delim delimiter to split on (default ',') @@ -1190,7 +1190,7 @@ namespace emp { std::stringstream msg; msg << "No assignment found in slice_assign() for: " << var_name; emp::notify::Exception("emp::string_utils::slice_assign::missing_assign", - msg.str(), var_name); + msg.str(), var_name); } result_map[var_name] = setting; } @@ -1408,7 +1408,7 @@ namespace emp { return emp::MakeString(c); } - + String MakeEscaped(const String & in) { return String(in, [](char c){ return MakeEscaped(c); }); } @@ -1529,7 +1529,7 @@ namespace emp { return out_string; } - template + template [[nodiscard]] T MakeFromLiteral(const String & value) { if (value.size() == 0) return T{}; diff --git a/include/emp/tools/char_utils.hpp b/include/emp/tools/char_utils.hpp index 8804577668..35906c4149 100644 --- a/include/emp/tools/char_utils.hpp +++ b/include/emp/tools/char_utils.hpp @@ -55,7 +55,7 @@ namespace emp { this_t & operator=(const this_t &) = default; this_t & operator=(char c) { Reset(); char_set[static_cast(c)] = true; } this_t & operator=(const std::string & in_chars) { - for (CHAR_T x : in_chars) char_set[static_cast(x)] = true; + for (CHAR_T x : in_chars) char_set[static_cast(x)] = true; } CharSetBase & Reset() { char_set.fill(0); } diff --git a/include/emp/tools/string_utils.hpp b/include/emp/tools/string_utils.hpp index 0d83630e99..706ed8ce0e 100644 --- a/include/emp/tools/string_utils.hpp +++ b/include/emp/tools/string_utils.hpp @@ -1003,7 +1003,7 @@ namespace emp { [[nodiscard]] inline std::string string_get_to(const std::string & in_string, const std::string & delim=" ", size_t start_pos=0) { - return string_get_range(in_string, start_pos, in_string.find(delim, start_pos)); + return string_get_range(in_string, start_pos, in_string.find(delim, start_pos)); } /// Remove a prefix of a string, up to the first whitespace, and return it. @@ -1310,7 +1310,7 @@ namespace emp { msg << "No assignment found in slice_assign(): " << in_string; abort(); emp::notify::Exception("emp::string_utils::slice_assign::missing_assign", - msg.str(), setting); + msg.str(), setting); } result_map[var_name] = setting; } @@ -1930,7 +1930,7 @@ namespace emp { return pos + 1; } - + /// Cut up a string based on the provided delimiter; fill them in to the provided vector. /// @param in_string string to be sliced /// @param out_set destination diff --git a/tests/bits/Bits.cpp b/tests/bits/Bits.cpp index 07e4c50227..42c3af140a 100644 --- a/tests/bits/Bits.cpp +++ b/tests/bits/Bits.cpp @@ -39,7 +39,7 @@ template void TestBasics(const T & bits, size_t _size, std::string vals="") { - + CHECK( bits.GetSize() == _size); if (vals == "") { return; } // No values to check. else if (vals == "Zeros") { CHECK(bits.CountOnes() == 0); } diff --git a/tests/math/RangeSet.cpp b/tests/math/RangeSet.cpp index 5240ff7320..55ca62795b 100644 --- a/tests/math/RangeSet.cpp +++ b/tests/math/RangeSet.cpp @@ -214,7 +214,7 @@ TEST_CASE("Test continuous RangeSets", "[math]") CHECK(rs1.HasOverlap(range_t(26.0,26.25)) == false); CHECK(rs1.GetSize() == Approx(44.25)); CHECK(rs1.GetNumRanges() == 93); - + // Remove middle of one range through middle of two later. CHECK(rs1.HasOverlap(range_t(29.0,31.0)) == true); rs1.RemoveRange(29.0,31.0); @@ -320,7 +320,7 @@ TEST_CASE("Test RangeSet operators to behave like Bits", "[math]") CHECK(input1.OK()); bv |= input1; CHECK(bv.OK()); - bv.Invert(); + bv.Invert(); CHECK(bv.KeepOnly(0,8) == set_t("01000000")); bv |= input1; bv.Invert(); CHECK(bv.KeepOnly(0,8) == set_t("10110000")); bv |= input2; bv.Invert(); CHECK(bv.KeepOnly(0,8) == set_t("01001100")); diff --git a/tests/tools/StaticString.cpp b/tests/tools/StaticString.cpp index 76d84479ea..dfebf1f1b0 100644 --- a/tests/tools/StaticString.cpp +++ b/tests/tools/StaticString.cpp @@ -64,7 +64,7 @@ TEST_CASE("ShortString manipulations", "[tools]") str1 = "test:"; str1.append("123"); CHECK(str1 == "test:123"); - + std::string str456 = "456"; str1.append(str456); CHECK(str1 == "test:123456"); diff --git a/tests/tools/String.cpp b/tests/tools/String.cpp index b23365767c..3f40027cd7 100644 --- a/tests/tools/String.cpp +++ b/tests/tools/String.cpp @@ -102,7 +102,7 @@ TEST_CASE("Test String Composition-ID Functions", "[tools]") CHECK(!emp::String("'\\'").IsLiteralChar()); CHECK(emp::MakeFromLiteral_Char("'f'") == 'f'); CHECK(emp::MakeFromLiteral_Char("'\n'") == '\n'); - + CHECK(emp::String("\"He llo!\"").IsLiteralString()); CHECK(!emp::String("\"\\\\He\"llo!\"").IsLiteralString()); CHECK(emp::String("\"Hel\n\t\r\\\'lo!\"").IsLiteralString()); @@ -120,7 +120,7 @@ TEST_CASE("Test String Composition-ID Functions", "[tools]") CHECK(special_string.CountDigits() == 3); CHECK(special_string.CountAlphanumeric() == 25); CHECK(special_string.CountNonwhitespace() == 30); - + /* CHECK(emp::is_valid("aaaaaaaaa", [](char x) { return (x == 'a'); } )); CHECK( !(emp::is_valid("aaaabaaaa", [](char x) { return (x == 'a'); })) ); @@ -325,7 +325,7 @@ TEST_CASE("Test String Conversion Functions", "[tools]") TEST_CASE("Test Stirng assign and Macro functions", "[tools]") -{ +{ emp::String test = "TIMES(abc,3) + TIMES(def,2) + TIMES(g, 8)"; test.ReplaceMacro("TIMES(", ")", [](emp::String check_body, size_t, size_t) {