{"id":16309787,"url":"https://github.com/w1th0utnam3/noname_tools","last_synced_at":"2025-07-06T20:39:08.365Z","repository":{"id":97282599,"uuid":"58885003","full_name":"w1th0utnam3/noname_tools","owner":"w1th0utnam3","description":"A collection of useful C++ methods and algorithms collected while working on other projects","archived":false,"fork":false,"pushed_at":"2020-05-11T20:51:17.000Z","size":493,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-01T03:54:17.129Z","etag":null,"topics":["algorithm","container","std","string","tuples","vector"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/w1th0utnam3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-15T21:21:21.000Z","updated_at":"2022-02-27T22:42:53.000Z","dependencies_parsed_at":"2023-04-11T18:18:13.560Z","dependency_job_id":null,"html_url":"https://github.com/w1th0utnam3/noname_tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/w1th0utnam3/noname_tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w1th0utnam3%2Fnoname_tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w1th0utnam3%2Fnoname_tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w1th0utnam3%2Fnoname_tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w1th0utnam3%2Fnoname_tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/w1th0utnam3","download_url":"https://codeload.github.com/w1th0utnam3/noname_tools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w1th0utnam3%2Fnoname_tools/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263969761,"owners_count":23537476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","container","std","string","tuples","vector"],"created_at":"2024-10-10T21:22:33.877Z","updated_at":"2025-07-06T20:39:08.350Z","avatar_url":"https://github.com/w1th0utnam3.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# noname_tools [![Build Status](https://github.com/w1th0utnam3/noname_tools/workflows/Build%20and%20test%20master/badge.svg)](https://github.com/w1th0utnam3/noname_tools/actions?query=workflow%3A%22Build+and+test+master%22)\r\n\r\nThis collection of C++ header files contains algorithms and small helper classes that accumulated \r\nfrom several small coding projects of mine. \r\nThe code of this project that is written by contributors of this repository is licensed under \r\nthe [MIT License](https://github.com/w1th0utnam3/noname_tools/blob/master/LICENSE). \r\n\r\n## Usage\r\n\r\nTo use the tools just copy the files from the `src/noname_tools` folder into your project. \r\nIncluding the `tools` file automatically includes all other headers. \r\nThe repository contains a project with test-cases for the tools. \r\nIt's based on the [Catch](https://github.com/philsquared/Catch) header-only unit-test framework \r\nwhich is licensed under the [Boost Software License](https://github.com/philsquared/Catch/blob/master/LICENSE_1_0.txt). \r\nCatch is included as a submodule. \r\nUse `git clone --recurse-submodules` to check out this repository including its submodules. \r\nCompilation is tested using [GitHub Actions](https://github.com/w1th0utnam3/noname_tools/actions?query=workflow%3A%22Build+and+test+master%22) \r\nwith VS2019, GCC 7.x, 8.x and 9.x, Clang 6.x, 8.x and 9.x in C++14 and C++17 mode of all compilers.   \r\n\r\nTo use the headers from this repo, you have to turn on C++14/C++17 support if this isn't your compiler's default setting. \r\nNote that you have to explicitly define the macro `NONAME_CPP14` before including any `noname_tools` header to \r\nmake sure that no C++17 feature is used by accident in the implementation.\r\n\r\n## Todos\r\n\r\n- Update this file with all implemented features\r\n- Add missing unit-tests\r\n- Additional features:\r\n  - string split iterator\r\n  - replace explicit container usages with iterators\r\n- Make `typelist_for_each` and `tuple_for_each` constexpr where possible\r\n\r\n## Included tools\r\n\r\nAt the moment `noname_tools` contains the following headers:\r\n\r\n- [`algorithm_tools.h`](#algorithm_toolsh) - Additional algorithms not present in `\u003calgorithm\u003e`\r\n- [`file_tools.h`](#file_toolsh) - Helper methods to read files to strings\r\n- `functional_tools.h` - Helpers related to callables (`apply_index_sequence`, `callable_container`...)\r\n- [`range_tools.h`](#range_toolsh) - Basic `iterator_range` type\r\n- `rtctmap_tools` - Functions to construct mappings for any type that can be used as a NTTP from a run-time argument to its corresponding value from a compile compile-time specified list of possible values\r\n- [`string_tools.h`](#string_toolsh) - String truncate, split...\r\n- [`tuple_tools.h`](#tuple_toolsh) - Operations on `std::tuple`\r\n- `typelist_tools.h` - Type and associated helpers to store and pass around lists of types, more lightweight alternative to using `std::tuple` in template metaprogramming\r\n- [`typetraits_tool.h`](#typetraits_toolssh) - C++20, C++17 and _Library fundamentals v2_ helpers for C++14 (`void_t`, `is_detected`,...)\r\n- [`utility_tools.h`](#utility_toolsh) - helper types\r\n- [`vector_tools.h`](#vector_toolsh) - Operations on `std::vector`\r\n\r\nBelow is a list of all types and functions from these headers. All declarations are in the `noname::tools` namespace.\r\n\r\n### algorithm_tools.h\r\n\r\n```c++\r\n//! Returns the first element in the specified range that is unequal to its predecessor, uses not-equal (!=) operator for comparison\r\nInputIt find_unequal_successor(InputIt first, InputIt last);\r\n//! Returns the first element in the specified range that is unequal to its predecessor, uses p to compare two elements for inequality\r\nInputIt find_unequal_successor(InputIt first, InputIt last, BinaryPredicate p);\r\n\r\n//! Applies the given function object to every element and its successor, returns copy/move of functor\r\nFunc for_each_and_successor(InputIt first, InputIt last, Func f);\r\n\r\n//! Divides a range in n (nearly) equal sized subranges and writes every subrange's begin- and end-iterator into dest without duplicates (i.e. dest will have n+1 entries)\r\nvoid n_subranges(InputIt first, InputIt last, OutputIt dest, std::size_t n);\r\n\r\n//! Copies the elements from the specified range to dest in such a way that all groups of consecutive equal objects are omitted, uses equal operator for comparison\r\nOutputIt strict_unique_copy(InputIt first, InputIt last, OutputIt dest);\r\n//! Copies the elements from the specified range to dest in such a way that all groups of consecutive equal objects are omitted, uses p to compare elements for equality\r\nOutputIt strict_unique_copy(InputIt first, InputIt last, OutputIt dest, BinaryPredicate p);\r\n```\r\n\r\n### file_tools.h\r\n\r\n```c++\r\n//! Reads all lines from the specified file to a vector\r\ninline std::vector\u003cstd::string\u003e read_all_lines(const std::string\u0026 file_path);\r\n\r\n//! Reads the specified number of lines from a file or reads the whole file if number of lines is zero\r\ninline std::vector\u003cstd::string\u003e read_lines(const std::string\u0026 file_path, size_t number_of_lines = 0);\r\n```\r\n\r\n### range_tools.h\r\n\r\n```c++\r\n//! Range object with begin() and end() methods to use range-based for loops with any pair of iterators, sentinel version (begin and end may be of different type)\r\nclass iterator_range\u003cbegin_t, end_t = void\u003e\r\n//! Range object with begin() and end() methods to use range-based for loops with any pair of iterators\r\nclass iterator_range\u003citerator_t\u003e\r\n\r\n//! Creates an iterator_range object, deducing the target type from the types of arguments\r\nconstexpr iterator_range\u003ctypename std::decay\u003cbegin_t\u003e::type, typename std::decay\u003cend_t\u003e::type\u003e make_range(begin_t\u0026\u0026 begin, end_t\u0026\u0026 end);\r\n```\r\n\r\n### string_tools.h\r\n\r\n```c++\r\n//! Truncates a string at the first occurrence of the specified character or returns the full string if the character was not found\r\nStringT truncate_string(const StringT\u0026 str, CharT ch);\r\n\r\n//! Returns a vector of substrings of the original string, split at every occurrence of the specified character\r\nstd::vector\u003cStringT\u003e split_string(const StringT\u0026 str, CharT ch);\r\n```\r\n\r\n### tuple_tools.h\r\n\r\n```c++\r\n//! Calls a function for each element of a tuple in order and returns the function\r\nF tuple_for_each(Tuple\u0026\u0026 tuple, F f);\r\n```\r\n\r\n### typetraits_tools.h\r\n\r\nSome type traits and helper types from the C++17 draft for use in C++14. Also includes the [detection idiom](http://en.cppreference.com/w/cpp/experimental/is_detected) alias templates from Library fundamentals v2.\r\n```c++\r\n//! Provides the member typedef type that names T (i.e., the identity transformation).\r\ntemplate\u003c class T \u003e\r\nstruct type_identity;\r\n\r\n//! Utility metafunction that maps a sequence of any types to the type void\r\ntemplate \u003ctypename... T\u003e\r\nusing void_t = ...;\r\n\r\n//! Helper alias template for std::integral_constant for the common case where T is bool.\r\ntemplate \u003cbool B\u003e\r\nusing bool_constant = ...;\r\n\r\n//! Forms the logical negation of the type trait B.\r\ntemplate\u003cclass B\u003e\r\nstruct negation : ...;\r\n//! Forms the logical conjunction of the type traits B..., effectively performing a logical AND on the sequence of traits.\r\ntemplate\u003cclass B1, class... Bn\u003e\r\nstruct conjunction\u003cB1, Bn...\u003e : ...;\r\n//! Forms the logical disjunction of the type traits B..., effectively performing a logical or on the sequence of traits.\r\ntemplate\u003cclass B1, class... Bn\u003e\r\nstruct disjunction\u003cB1, Bn...\u003e : ...;\r\n\r\n//! Class type used by detected_t to indicate detection failure. \r\nstruct nonesuch;\r\n//! Alias for std::true_type if the template-id Op\u003cArgs...\u003e is valid; otherwise it is an alias for std::false_type. \r\ntemplate \u003ctemplate\u003cclass...\u003e class Op, class... Args\u003e\r\nusing is_detected = ...;\r\n//! Alias for Op\u003cArgs...\u003e if that template-id is valid; otherwise it is an alias for the class nonesuch. \r\ntemplate \u003ctemplate\u003cclass...\u003e class Op, class... Args\u003e\r\nusing detected_t = ...;\r\n//! If the template-id Op\u003cArgs...\u003e is valid, then value_t is an alias for std::true_type, and type is an alias for Op\u003cArgs...\u003e; Otherwise, value_t is an alias for std::false_type and type is an alias for Default.\r\ntemplate \u003cclass Default, template\u003cclass...\u003e class Op, class... Args\u003e\r\nusing detected_or = ...;\r\n//! Checks whether detected_t\u003cOp, Args...\u003e is Expected.  \r\ntemplate \u003cclass Expected, template\u003cclass...\u003e class Op, class... Args\u003e\r\nusing is_detected_exact = ...;\r\n//! Checks whether detected_t\u003cOp, Args...\u003e is convertible to To.\r\ntemplate \u003cclass To, template\u003cclass...\u003e class Op, class... Args\u003e\r\nusing is_detected_convertible = ...;\r\n\r\n//! Checks if the supplied type is referenceable, i.e. whether T\u0026 is a well-formed type\r\ntemplate\u003cclass T\u003e\r\nusing is_referenceable = ...;\r\n\r\n//! Checks if the expressions swap(std::declval\u003cT\u003e(), std::declval\u003cU\u003e()) and swap(std::declval\u003cU\u003e(), std::declval\u003cT\u003e()) are both well formed after \"using std::swap\"\r\ntemplate\u003cclass T, class U\u003e\r\nusing is_swappable_with = ...;\r\n\r\n//! Checks if a type is referenceable and whether std::is_swappable_with\u003cT\u0026, T\u0026\u003e::value is true\r\ntemplate\u003cclass T\u003e\r\nusing is_swappable = ...;\r\n\r\n//! Combines std::remove_cv and std::remove_reference\r\ntemplate\u003cclass T\u003e\r\nstruct remove_cvref;\r\n//! Helper for remove_cvref, defined as remove_cvref::type.\r\ntemplate\u003cclass T\u003e\r\nusing remove_cvref_t = typename remove_cvref\u003cT\u003e::type;\r\n```\r\n\r\n### utility_tools.h\r\n```c++\r\n//! Alias for the 'I'-th element of 'Ts'.\r\ntemplate \u003cstd::size_t I, typename ...Ts\u003e\r\nstruct nth_element : ...;\r\n//! Returns the index of the first occurrence of 'T' in 'Ts...' or element_not_found.\r\ntemplate \u003ctypename T, typename... Ts\u003e\r\nstruct element_index : ...;\r\n//! Counts the number of occurrences of 'T' in 'Ts...'.\r\ntemplate\u003ctypename T, typename... Ts\u003e\r\nstruct count_element : ...;\r\n//! Checks whether every element occurs only once in 'Ts'.\r\ntemplate \u003ctypename... Ts\u003e\r\nstruct unique_elements\r\n```\r\n\r\n### vector_tools.h\r\n\r\n```c++\r\n//! Returns a sorted vector constructed from the supplied initializer list\r\nstd::vector\u003cT\u003e sorted_vector(std::initializer_list\u003cT\u003e in);\r\n//! Sorts the supplied r-value vector and returns it\r\nstd::vector\u003cT\u003e sorted_vector(std::vector\u003cT\u003e\u0026\u0026 vector);\r\n//! Initializes a vector by moving all supplied elements into it\r\nstd::vector\u003c...\u003e move_construct_vector(Ts\u0026\u0026... elements);\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw1th0utnam3%2Fnoname_tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fw1th0utnam3%2Fnoname_tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw1th0utnam3%2Fnoname_tools/lists"}