{"id":20077212,"url":"https://github.com/boostorg/stl_interfaces","last_synced_at":"2025-04-06T09:07:32.051Z","repository":{"id":45466083,"uuid":"200397382","full_name":"boostorg/stl_interfaces","owner":"boostorg","description":"A C++14 and later CRTP template for defining iterators","archived":false,"fork":false,"pushed_at":"2024-10-24T01:46:30.000Z","size":1972,"stargazers_count":70,"open_issues_count":4,"forks_count":22,"subscribers_count":8,"default_branch":"develop","last_synced_at":"2024-10-24T17:44:58.583Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boostorg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE_1_0.txt","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-08-03T16:30:13.000Z","updated_at":"2024-10-24T01:46:34.000Z","dependencies_parsed_at":"2024-01-21T22:49:19.646Z","dependency_job_id":"7aec2d5f-3f9c-44de-ac81-2e7c1a55c337","html_url":"https://github.com/boostorg/stl_interfaces","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostorg%2Fstl_interfaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostorg%2Fstl_interfaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostorg%2Fstl_interfaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boostorg%2Fstl_interfaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boostorg","download_url":"https://codeload.github.com/boostorg/stl_interfaces/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457800,"owners_count":20941906,"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":[],"created_at":"2024-11-13T15:06:35.435Z","updated_at":"2025-04-06T09:07:32.031Z","avatar_url":"https://github.com/boostorg.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stl_interfaces\n\nAn updated C++20-friendly version of the `iterator_facade` and\n`iterator_adaptor` parts of Boost.Iterator (now called `iterator_interface`);\na pre-C++20 version of C++20's `view_interface`; and a new template called\n`container_interface`, meant to aid the creation of new containers; all\ntargeting standardization.  This library requires at least C++14.\n\nFor the iterator portion -- if you need to write an iterator, `iterator_interface` turns this:\n\n```c++\n    struct repeated_chars_iterator\n    {\n        using value_type = char;\n        using difference_type = std::ptrdiff_t;\n        using pointer = char const *;\n        using reference = char const;\n        using iterator_category = std::random_access_iterator_tag;\n\n        constexpr repeated_chars_iterator() noexcept :\n            first_(nullptr),\n            size_(0),\n            n_(0)\n        {}\n        constexpr repeated_chars_iterator(\n            char const * first,\n            difference_type size,\n            difference_type n) noexcept :\n            first_(first),\n            size_(size),\n            n_(n)\n        {}\n\n        constexpr reference operator*() const noexcept\n        {\n            return first_[n_ % size_];\n        }\n\n        constexpr value_type operator[](difference_type n) const noexcept\n        {\n            return first_[(n_ + n) % size_];\n        }\n\n        constexpr repeated_chars_iterator \u0026 operator++() noexcept\n        {\n            ++n_;\n            return *this;\n        }\n        constexpr repeated_chars_iterator operator++(int)noexcept\n        {\n            repeated_chars_iterator retval = *this;\n            ++*this;\n            return retval;\n        }\n        constexpr repeated_chars_iterator \u0026 operator+=(difference_type n) noexcept\n        {\n            n_ += n;\n            return *this;\n        }\n\n        constexpr repeated_chars_iterator \u0026 operator--() noexcept\n        {\n            --n_;\n            return *this;\n        }\n        constexpr repeated_chars_iterator operator--(int)noexcept\n        {\n            repeated_chars_iterator retval = *this;\n            --*this;\n            return retval;\n        }\n        constexpr repeated_chars_iterator \u0026 operator-=(difference_type n) noexcept\n        {\n            n_ -= n;\n            return *this;\n        }\n\n        friend constexpr bool operator==(\n            repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept\n        {\n            return lhs.first_ == rhs.first_ \u0026\u0026 lhs.n_ == rhs.n_;\n        }\n        friend constexpr bool operator!=(\n            repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept\n        {\n            return !(lhs == rhs);\n        }\n        friend constexpr bool operator\u003c(\n            repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept\n        {\n            return lhs.first_ == rhs.first_ \u0026\u0026 lhs.n_ \u003c rhs.n_;\n        }\n        friend constexpr bool operator\u003c=(\n            repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept\n        {\n            return lhs == rhs || lhs \u003c rhs;\n        }\n        friend constexpr bool operator\u003e(\n            repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept\n        {\n            return rhs \u003c lhs;\n        }\n        friend constexpr bool operator\u003e=(\n            repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept\n        {\n            return rhs \u003c= lhs;\n        }\n\n        friend constexpr repeated_chars_iterator\n        operator+(repeated_chars_iterator lhs, difference_type rhs) noexcept\n        {\n            return lhs += rhs;\n        }\n        friend constexpr repeated_chars_iterator\n        operator+(difference_type lhs, repeated_chars_iterator rhs) noexcept\n        {\n            return rhs += lhs;\n        }\n        friend constexpr repeated_chars_iterator\n        operator-(repeated_chars_iterator lhs, difference_type rhs) noexcept\n        {\n            return lhs -= rhs;\n        }\n        friend constexpr difference_type operator-(\n            repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept\n        {\n            return lhs.n_ - rhs.n_;\n        }\n\n    private:\n        char const * first_;\n        difference_type size_;\n        difference_type n_;\n    };\n```\n\ninto this:\n\n```c++\nstruct repeated_chars_iterator : boost::stl_interfaces::iterator_interface\u003c\n                                     repeated_chars_iterator,\n                                     std::random_access_iterator_tag,\n                                     char,\n                                     char\u003e\n{\n    constexpr repeated_chars_iterator() noexcept :\n        first_(nullptr),\n        size_(0),\n        n_(0)\n    {}\n    constexpr repeated_chars_iterator(\n        char const * first, difference_type size, difference_type n) noexcept :\n        first_(first),\n        size_(size),\n        n_(n)\n    {}\n\n    constexpr char operator*() const noexcept { return first_[n_ % size_]; }\n    constexpr repeated_chars_iterator \u0026 operator+=(std::ptrdiff_t i) noexcept\n    {\n        n_ += i;\n        return *this;\n    }\n    constexpr auto operator-(repeated_chars_iterator other) const noexcept\n    {\n        return n_ - other.n_;\n    }\n\nprivate:\n    char const * first_;\n    difference_type size_;\n    difference_type n_;\n};\n```\n\nThe code size savings are even more dramatic for `view_interface` and\n`container_interface`! If you don't ever write iterators, views, containers,\nor view adaptors, this is not for you.\n\nThis library includes both C++20 concept constrained and SFINAE-constrained\nversions.\n\n[![License](https://img.shields.io/badge/license-boost-brightgreen.svg)](LICENSE_1_0.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboostorg%2Fstl_interfaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboostorg%2Fstl_interfaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboostorg%2Fstl_interfaces/lists"}