{"id":15048056,"url":"https://github.com/pinam45/dynamic_bitset","last_synced_at":"2025-10-05T14:39:50.196Z","repository":{"id":44196757,"uuid":"173188612","full_name":"pinam45/dynamic_bitset","owner":"pinam45","description":"Simple Useful Libraries: C++17/20 header-only dynamic bitset","archived":false,"fork":false,"pushed_at":"2025-02-04T20:26:38.000Z","size":918,"stargazers_count":161,"open_issues_count":1,"forks_count":15,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-25T03:03:40.240Z","etag":null,"topics":["catch2","cmake","cpp17","cpp20","header-only","sul","unit-tests"],"latest_commit_sha":null,"homepage":"https://pinam45.github.io/dynamic_bitset","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/pinam45.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":"2019-02-28T21:16:16.000Z","updated_at":"2025-04-27T09:06:13.000Z","dependencies_parsed_at":"2024-10-27T14:53:47.774Z","dependency_job_id":"f672cf5b-a578-4f86-9f37-5b986454bba1","html_url":"https://github.com/pinam45/dynamic_bitset","commit_stats":{"total_commits":209,"total_committers":1,"mean_commits":209.0,"dds":0.0,"last_synced_commit":"9694eda32f6a75516a9b4e659f9d1a855dfe4800"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/pinam45/dynamic_bitset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinam45%2Fdynamic_bitset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinam45%2Fdynamic_bitset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinam45%2Fdynamic_bitset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinam45%2Fdynamic_bitset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pinam45","download_url":"https://codeload.github.com/pinam45/dynamic_bitset/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinam45%2Fdynamic_bitset/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278466643,"owners_count":25991656,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["catch2","cmake","cpp17","cpp20","header-only","sul","unit-tests"],"created_at":"2024-09-24T21:07:32.810Z","updated_at":"2025-10-05T14:39:50.168Z","avatar_url":"https://github.com/pinam45.png","language":"C++","readme":"# dynamic_bitset\n\n[![Ubuntu](https://github.com/pinam45/dynamic_bitset/actions/workflows/ubuntu.yml/badge.svg?branch=master)](https://github.com/pinam45/dynamic_bitset/actions/workflows/ubuntu.yml)\n[![Windows MSYS2](https://github.com/pinam45/dynamic_bitset/actions/workflows/windows-msys2.yml/badge.svg?branch=master)](https://github.com/pinam45/dynamic_bitset/actions/workflows/windows-msys2.yml)\n[![Windows Visual Studio](https://github.com/pinam45/dynamic_bitset/actions/workflows/windows-msvc.yml/badge.svg?branch=master)](https://github.com/pinam45/dynamic_bitset/actions/workflows/windows-msvc.yml)\n[![macOS](https://github.com/pinam45/dynamic_bitset/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/pinam45/dynamic_bitset/actions/workflows/macos.yml)\n[![documentation](https://github.com/pinam45/dynamic_bitset/actions/workflows/documentation.yml/badge.svg?branch=master)](https://pinam45.github.io/dynamic_bitset)\n[![codecov](https://codecov.io/gh/pinam45/dynamic_bitset/branch/master/graph/badge.svg)](https://codecov.io/gh/pinam45/dynamic_bitset)\n[![license](https://img.shields.io/github/license/pinam45/dynamic_bitset.svg)](http://opensource.org/licenses/MIT)\n\nSimple Useful Libraries: C++17/20 header-only dynamic bitset\n\n## Requirements\n\nTo use this *dynamic bitset*, you will need a **C++17 (or later) compliant compiler**. If you use CMake and want to use the *dynamic bitset* as a subproject, you will need **CMake 3.10 or later**.\n\n## Usage sample\n\n```cpp\n#include \u003csul/dynamic_bitset.hpp\u003e\n#include \u003ciostream\u003e\n#include \u003crandom\u003e\n\nint main()\n{\n\t// predefined bitset\n\tsul::dynamic_bitset\u003c\u003e bitset1(12, 0b0100010110111);\n\tstd::cout \u003c\u003c \"bitset1     = \" \u003c\u003c bitset1 \u003c\u003c std::endl;\n\n\t// random bitset\n\tstd::minstd_rand rand(std::random_device{}());\n\tstd::bernoulli_distribution dist;\n\tsul::dynamic_bitset\u003c\u003e bitset2;\n\tfor(size_t i = 0; i \u003c 12; ++i)\n\t{\n\t\tbitset2.push_back(dist(rand));\n\t}\n\tstd::cout \u003c\u003c \"bitset2     = \" \u003c\u003c bitset2 \u003c\u003c std::endl;\n\n\tstd::cout \u003c\u003c \"common bits = \" \u003c\u003c (bitset1 \u0026 bitset2) \u003c\u003c std::endl;\n\treturn 0;\n}\n```\n\nPossible output:\n\n    bitset1     = 100010110111\n    bitset2     = 001011011011\n    common bits = 000010010011\n\nTest it on [godbolt.org](https://godbolt.org/z/1veE71rYT).\n\n## Optional dependency\n\nOptionally, [libpopcnt](https://github.com/kimwalisch/libpopcnt) will be used to optimize the bits counting operations, if the header is available (``__has_include(\u003clibpopcnt.h\u003e)``) and ``DYNAMIC_BITSET_NO_LIBPOPCNT`` is not defined.\n\n## Integration\n\nAs it is a header-only library, the easiest way to integrate the *sul::dynamic_bitset* class in your project is to just copy the [sul](include/sul) folder in your project sources. Optionally, if you also copy *libpopcnt.h* from [libpopcnt](https://github.com/kimwalisch/libpopcnt), it will be used by default if it is available.\n\n## CMake integration\n\nIf you use CMake and want to use the *dynamic bitset* as a subproject, clone the repository (or add it as a git submodule) in a sub-folder of your project. Then, in your *CMakeLists.txt* add:\n```CMake\nadd_subdirectory(\u003cpath_to_dynamic_bitset_folder\u003e)\n```\nIt will define the *dynamic_bitset* target and the alias target *sul::dynamic_bitset* that you can use to add the folder containing *dynamic_bitset.hpp* to your project header folders. To do so, in your *CMakeLists.txt* add:\n```CMake\ntarget_link_libraries(\u003cyour_project_target\u003e PRIVATE sul::dynamic_bitset)\n```\n\nFor example, a simple project with the repository as a git submodule in the *extlibs* folder, could have a *CMakeLists.txt* similar to this:\n```CMake\ncmake_minimum_required(VERSION 3.10)\nproject(CoolProject LANGUAGES CXX)\n\nadd_executable(CoolProject main.cpp)\ntarget_compile_features(CoolProject PRIVATE cxx_std_20)\n\nadd_subdirectory(extlibs/dynamic_bitset)\ntarget_link_libraries(CoolProject PRIVATE sul::dynamic_bitset)\n```\n\nIf you pulled the git submodule libpopcnt (in [extlibs](extlibs)) and set the *dynamic bitset* CMake options ``DYNAMICBITSET_USE_LIBPOPCNT`` and ``DYNAMICBITSET_USE_LIBPOPCNT_SUBMODULE`` to ``ON``(default values), the folder containing *libpopcnt.h* will also be added to the headers paths and libpopcnt will be used.\n\n## CMake options\n\n### Descriptions\n\n- ``DYNAMICBITSET_NO_NAMESPACE``: Put the dynamic_bitset class in the global namespace instead of the sul namespace (not recommended)\n- ``DYNAMICBITSET_USE_LIBPOPCNT``: Enable using libpopcnt for bits counting operations\n- ``DYNAMICBITSET_USE_LIBPOPCNT_SUBMODULE``: Enable adding libpopcnt submodule to include paths (disable if your project already include libpopcnt)\n- ``DYNAMICBITSET_USE_STD_BITOPS``: Enable using (if available) C++20 binary operations from the bit header\n- ``DYNAMICBITSET_USE_COMPILER_BUILTIN``: Enable using (if available) compiler builtins (if using C++20 binary operations is disabled or not possible)\n- ``DYNAMICBITSET_BUILD_EXAMPLE``: Enable building example for dynamic_bitset\n- ``DYNAMICBITSET_BUILD_TESTS``: Enable building tests for dynamic_bitset\n- ``DYNAMICBITSET_BUILD_DOCS``: Enable building documentation for dynamic_bitset\n- ``DYNAMICBITSET_FORMAT_TARGET``: Enable generating a code formating target for dynamic_bitset\n- ``DYNAMICBITSET_HEADERS_TARGET_IDE``: Enable generating a target with headers for ide for dynamic_bitset\n\n### Default values\n\n| Option                                | Default value as top level project | Default value as subdirectory |\n| ------------------------------------- | :--------------------------------: | :---------------------------: |\n| DYNAMICBITSET_NO_NAMESPACE            | OFF                                | OFF                           |\n| DYNAMICBITSET_USE_LIBPOPCNT           | ON                                 | ON                            |\n| DYNAMICBITSET_USE_LIBPOPCNT_SUBMODULE | ON                                 | ON                            |\n| DYNAMICBITSET_USE_STD_BITOPS          | ON                                 | ON                            |\n| DYNAMICBITSET_USE_COMPILER_BUILTIN    | ON                                 | ON                            |\n| DYNAMICBITSET_BUILD_EXAMPLE           | ON                                 | OFF                           |\n| DYNAMICBITSET_BUILD_TESTS             | ON                                 | OFF                           |\n| DYNAMICBITSET_BUILD_DOCS              | ON                                 | OFF                           |\n| DYNAMICBITSET_FORMAT_TARGET           | ON                                 | OFF                           |\n| DYNAMICBITSET_HEADERS_TARGET_IDE      | ON                                 | OFF                           |\n\n## Build tests, example, and documentation\n\n\u003e [!NOTE]\n\u003e The latest version of the documentation is available online [here](https://pinam45.github.io/dynamic_bitset).\n\nTo build the tests, the example, and the documentation, git submodules are required, so don't forget to pull the submodules with the repository using ``--recursive``:\n\n    $ git clone --recursive https://github.com/pinam45/dynamic_bitset.git\n\nor if you have already cloned the repository:\n\n    $ git submodule update --init --recursive\n\nThe project uses CMake to build and define the options ``DYNAMICBITSET_BUILD_TESTS``, ``DYNAMICBITSET_BUILD_EXAMPLE``, and ``DYNAMICBITSET_BUILD_DOCS`` to enable the generation of the tests, example, and documentation targets, these option are enabled by default if the project is the master project (not included from another *CMakeLists.txt* with *add_subdirectory*).\n\nGenerating the documentation requires **[Doxygen](http://www.doxygen.nl/) 1.9.6 or later** and is done by building the target *dynamic_bitset_docs*. For running the tests, build the *dynamic_bitset_tests* target and launch the tests using ctest.\n\nSee [Running CMake](https://cmake.org/runningcmake/) and [the ctest documentation](https://cmake.org/cmake/help/latest/manual/ctest.1.html) for more information. On linux, a common way of doing this is:\n\n\t$ mkdir cmake-build\n\t$ cd cmake-build\n\t$ cmake ..\n\t$ cmake --build .\n\t$ ctest --output-on-failure\n\nOn Windows, there is batch files available to configure a Visual Studio project in the [ide](ide) folder.\n\n## License\n\ndynamic_bitset is licensed under the [MIT License](http://opensource.org/licenses/MIT):\n\nCopyright \u0026copy; 2019 [Maxime Pinard](https://github.com/pinam45)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":["Containers","Data Structures and Algorithms"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinam45%2Fdynamic_bitset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinam45%2Fdynamic_bitset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinam45%2Fdynamic_bitset/lists"}