{"action":"created","comment":{"url":"https://api.github.com/repos/dlang/phobos/pulls/comments/91836911","pull_request_review_id":12349497,"id":91836911,"diff_hunk":"@@ -9594,6 +9594,514 @@ auto refRange(R)(R* range)\n     foo(r);\n }\n \n+/**\n+Bitwise adapter over integral type ranges. Consumes the range elements bit by bit.\n+*/\n+struct Bitwise(R)\n+    if (isInputRange!R && isIntegral!(ElementType!R))\n+{\n+private:\n+    alias ElemType = ElementType!R;\n+    alias UnsignedElemType = Unsigned!ElemType;\n+\n+    R parent;\n+\n+    enum bitsNum = ElemType.sizeof * 8;\n+    size_t maskPos = bitsNum;\n+\n+    static if (hasLength!R)\n+    {\n+        ulong len;\n+    }\n+\n+    static if (isBidirectionalRange!R)\n+    {\n+        size_t backMaskPos = 1;\n+    }\n+\n+public:\n+    this()(auto ref R range)\n+    {\n+        parent = range;\n+\n+        static if (hasLength!R)\n+        {\n+            len = parent.length * bitsNum;\n+        }\n+    }\n+\n+    bool empty()\n+    {\n+        static if (hasLength!R)\n+        {\n+            return len == 0;\n+        }\n+        else static if (isBidirectionalRange!R)\n+        {\n+            bool isOverlapping = parent.empty;\n+\n+            if (!parent.empty)\n+            {\n+                /*\n+                   If we have consumed the last element of the range both from\n+                   the front and the back, then the masks positions will overlap\n+                 */\n+                R parentCopy = parent.save;\n+\n+                parentCopy.popFront;\n+                isOverlapping = parentCopy.empty && (maskPos < backMaskPos);\n+            }\n+\n+            return parent.empty || isOverlapping;\n+        }\n+        else\n+        {\n+            /*\n+               If we consumed the last element of the range, but not all the\n+               bits in the last element\n+             */\n+            return parent.empty;\n+        }\n+    }\n+\n+    bool front()\n+    {\n+        assert(!empty());\n+\n+        return (parent.front & mask(maskPos)) != 0;\n+    }\n+\n+    void popFront()\n+    {\n+        --maskPos;\n+\n+        if (maskPos == 0)\n+        {\n+            parent.popFront;\n+            maskPos = bitsNum;\n+        }\n+\n+        static if (hasLength!R)\n+        {\n+            --len;\n+        }\n+    }\n+\n+    static if (hasLength!R)\n+    {\n+        ulong length() const\n+        {\n+            return len;\n+        }\n+\n+        alias opDollar = length;\n+    }\n+\n+    static if (isForwardRange!R)\n+    {\n+        typeof(this) save()\n+        {\n+            auto result = this;\n+            result.parent = parent.save;\n+            return result;\n+        }\n+    }\n+\n+    static if (isBidirectionalRange!R)\n+    {\n+        bool back()\n+        {\n+            assert(!empty());\n+\n+            return (parent.back & mask(backMaskPos)) != 0;\n+        }\n+\n+        void popBack()\n+        {\n+            ++backMaskPos;\n+\n+            if (backMaskPos > bitsNum)\n+            {\n+                parent.popBack;\n+                backMaskPos = 1;\n+            }\n+\n+            static if (hasLength!R)\n+            {\n+                --len;\n+            }\n+        }\n+    }\n+\n+    static if (isRandomAccessRange!R)\n+    {\n+        /**\n+          Return the `n`th bit within the range\n+         */\n+        bool opIndex(size_t n)\n+        in\n+        {\n+            assert(n >= 0);\n+            // TODO slice.d 2527\n+\n+            /*\n+               If it does not have the length property, it means that R is\n+               an infinite range\n+             */\n+            static if (hasLength!R)\n+            {\n+                assert(n < len,\n+                       __PRETTY_FUNCTION__ ~ \": Index out of bounds\");\n+            }\n+        }\n+        body\n+        {\n+            if (maskPos > n)\n+            {\n+                return (parent.front & mask(maskPos - n)) != 0;\n+            }\n+\n+            n -= maskPos;\n+\n+            /*\n+               By truncating n with maskPos bits we have skipped the remaining\n+               maskPos bits in parent[0], so we need to add 1 to elemIndex.\n+             */\n+            size_t elemIndex = n / bitsNum + 1;\n+\n+            /*\n+               Since the indexing is from MSB to LSB, we need to subtract the\n+               remainder from the number of bits that the element type has.\n+\n+               Because bitsNum is a power of 2, n % bitsNum == n & (bitsNum - 1)\n+             */\n+            uint elemMaskPos = bitsNum - (n & (bitsNum - 1));\n+\n+            return (parent[elemIndex] & mask(elemMaskPos)) != 0;\n+        }\n+\n+        bool opIndexAssign(bool flag, size_t n)\n+        in\n+        {\n+            assert(n >= 0);\n+            static if (hasLength!R)\n+            {\n+                assert(n < len,\n+                       __PRETTY_FUNCTION__ ~ \": Index out of bounds\");\n+            }\n+        }\n+        body\n+        {\n+            size_t elemMaskPos;\n+            size_t elemIndex;\n+\n+            if (maskPos > n)\n+            {\n+                elemMaskPos = maskPos - n;\n+                elemIndex = 0;\n+            }\n+            else\n+            {\n+                n -= maskPos;\n+                elemMaskPos = bitsNum - (n & (bitsNum - 1));\n+                elemIndex = n / bitsNum + 1;\n+            }\n+\n+            auto elem = parent[elemIndex];\n+            auto elemMask = mask(elemMaskPos);\n+\n+            if (flag)\n+            {\n+                elem |= elemMask;\n+            }\n+            else\n+            {\n+                elem &= ~elemMask;\n+            }\n+            parent[elemIndex] = elem;\n+\n+            return flag;\n+        }\n+\n+        Bitwise!R opSlice()\n+        {\n+            return this;\n+        }\n+\n+        Bitwise!R opSlice(size_t start, size_t end)\n+        in\n+        {\n+            assert(start < end);\n+        }\n+        body\n+        {\n+            size_t sliceLen = end - start;\n+            size_t startElemIndex;\n+            size_t endElemIndex;","path":"std/range/package.d","position":247,"original_position":247,"commit_id":"1c35ce0516cf75452bb027f75dbbeefc04efdd97","original_commit_id":"c3e620e02ecbc4e9ec9459ea5fb284854e7b05e8","user":{"login":"andralex","id":566679,"avatar_url":"https://avatars.githubusercontent.com/u/566679?v=3","gravatar_id":"","url":"https://api.github.com/users/andralex","html_url":"https://github.com/andralex","followers_url":"https://api.github.com/users/andralex/followers","following_url":"https://api.github.com/users/andralex/following{/other_user}","gists_url":"https://api.github.com/users/andralex/gists{/gist_id}","starred_url":"https://api.github.com/users/andralex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andralex/subscriptions","organizations_url":"https://api.github.com/users/andralex/orgs","repos_url":"https://api.github.com/users/andralex/repos","events_url":"https://api.github.com/users/andralex/events{/privacy}","received_events_url":"https://api.github.com/users/andralex/received_events","type":"User","site_admin":false},"body":"move down closest to initialization point","created_at":"2016-12-10T15:28:41Z","updated_at":"2016-12-10T15:28:41Z","html_url":"https://github.com/dlang/phobos/pull/4927#discussion_r91836911","pull_request_url":"https://api.github.com/repos/dlang/phobos/pulls/4927","_links":{"self":{"href":"https://api.github.com/repos/dlang/phobos/pulls/comments/91836911"},"html":{"href":"https://github.com/dlang/phobos/pull/4927#discussion_r91836911"},"pull_request":{"href":"https://api.github.com/repos/dlang/phobos/pulls/4927"}}},"pull_request":{"url":"https://api.github.com/repos/dlang/phobos/pulls/4927","id":95895465,"html_url":"https://github.com/dlang/phobos/pull/4927","diff_url":"https://github.com/dlang/phobos/pull/4927.diff","patch_url":"https://github.com/dlang/phobos/pull/4927.patch","issue_url":"https://api.github.com/repos/dlang/phobos/issues/4927","number":4927,"state":"open","locked":false,"title":"[WIP] std.range: implement bitwise adapter over Integral type Ranges","user":{"login":"edi33416","id":3812633,"avatar_url":"https://avatars.githubusercontent.com/u/3812633?v=3","gravatar_id":"","url":"https://api.github.com/users/edi33416","html_url":"https://github.com/edi33416","followers_url":"https://api.github.com/users/edi33416/followers","following_url":"https://api.github.com/users/edi33416/following{/other_user}","gists_url":"https://api.github.com/users/edi33416/gists{/gist_id}","starred_url":"https://api.github.com/users/edi33416/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edi33416/subscriptions","organizations_url":"https://api.github.com/users/edi33416/orgs","repos_url":"https://api.github.com/users/edi33416/repos","events_url":"https://api.github.com/users/edi33416/events{/privacy}","received_events_url":"https://api.github.com/users/edi33416/received_events","type":"User","site_admin":false},"body":"Add a generic bitwise adapter to std.range","created_at":"2016-11-30T13:55:38Z","updated_at":"2016-12-10T15:30:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cf441bf4c48e1377c85d686b60f94728b405150d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dlang/phobos/pulls/4927/commits","review_comments_url":"https://api.github.com/repos/dlang/phobos/pulls/4927/comments","review_comment_url":"https://api.github.com/repos/dlang/phobos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dlang/phobos/issues/4927/comments","statuses_url":"https://api.github.com/repos/dlang/phobos/statuses/1c35ce0516cf75452bb027f75dbbeefc04efdd97","head":{"label":"edi33416:bitwise_adapter","ref":"bitwise_adapter","sha":"1c35ce0516cf75452bb027f75dbbeefc04efdd97","user":{"login":"edi33416","id":3812633,"avatar_url":"https://avatars.githubusercontent.com/u/3812633?v=3","gravatar_id":"","url":"https://api.github.com/users/edi33416","html_url":"https://github.com/edi33416","followers_url":"https://api.github.com/users/edi33416/followers","following_url":"https://api.github.com/users/edi33416/following{/other_user}","gists_url":"https://api.github.com/users/edi33416/gists{/gist_id}","starred_url":"https://api.github.com/users/edi33416/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edi33416/subscriptions","organizations_url":"https://api.github.com/users/edi33416/orgs","repos_url":"https://api.github.com/users/edi33416/repos","events_url":"https://api.github.com/users/edi33416/events{/privacy}","received_events_url":"https://api.github.com/users/edi33416/received_events","type":"User","site_admin":false},"repo":{"id":73472663,"name":"phobos","full_name":"edi33416/phobos","owner":{"login":"edi33416","id":3812633,"avatar_url":"https://avatars.githubusercontent.com/u/3812633?v=3","gravatar_id":"","url":"https://api.github.com/users/edi33416","html_url":"https://github.com/edi33416","followers_url":"https://api.github.com/users/edi33416/followers","following_url":"https://api.github.com/users/edi33416/following{/other_user}","gists_url":"https://api.github.com/users/edi33416/gists{/gist_id}","starred_url":"https://api.github.com/users/edi33416/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edi33416/subscriptions","organizations_url":"https://api.github.com/users/edi33416/orgs","repos_url":"https://api.github.com/users/edi33416/repos","events_url":"https://api.github.com/users/edi33416/events{/privacy}","received_events_url":"https://api.github.com/users/edi33416/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/edi33416/phobos","description":"The standard library of the D programming language","fork":true,"url":"https://api.github.com/repos/edi33416/phobos","forks_url":"https://api.github.com/repos/edi33416/phobos/forks","keys_url":"https://api.github.com/repos/edi33416/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edi33416/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edi33416/phobos/teams","hooks_url":"https://api.github.com/repos/edi33416/phobos/hooks","issue_events_url":"https://api.github.com/repos/edi33416/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/edi33416/phobos/events","assignees_url":"https://api.github.com/repos/edi33416/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/edi33416/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/edi33416/phobos/tags","blobs_url":"https://api.github.com/repos/edi33416/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edi33416/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edi33416/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/edi33416/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edi33416/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/edi33416/phobos/languages","stargazers_url":"https://api.github.com/repos/edi33416/phobos/stargazers","contributors_url":"https://api.github.com/repos/edi33416/phobos/contributors","subscribers_url":"https://api.github.com/repos/edi33416/phobos/subscribers","subscription_url":"https://api.github.com/repos/edi33416/phobos/subscription","commits_url":"https://api.github.com/repos/edi33416/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/edi33416/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/edi33416/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/edi33416/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/edi33416/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/edi33416/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edi33416/phobos/merges","archive_url":"https://api.github.com/repos/edi33416/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edi33416/phobos/downloads","issues_url":"https://api.github.com/repos/edi33416/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/edi33416/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/edi33416/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/edi33416/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edi33416/phobos/labels{/name}","releases_url":"https://api.github.com/repos/edi33416/phobos/releases{/id}","deployments_url":"https://api.github.com/repos/edi33416/phobos/deployments","created_at":"2016-11-11T11:34:18Z","updated_at":"2016-11-11T11:34:22Z","pushed_at":"2016-12-10T15:24:46Z","git_url":"git://github.com/edi33416/phobos.git","ssh_url":"git@github.com:edi33416/phobos.git","clone_url":"https://github.com/edi33416/phobos.git","svn_url":"https://github.com/edi33416/phobos","homepage":"dlang.org/phobos","size":47570,"stargazers_count":0,"watchers_count":0,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dlang:master","ref":"master","sha":"59065e7b69743b90e8e370d6478816f27bcc7a61","user":{"login":"dlang","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/dlang","html_url":"https://github.com/dlang","followers_url":"https://api.github.com/users/dlang/followers","following_url":"https://api.github.com/users/dlang/following{/other_user}","gists_url":"https://api.github.com/users/dlang/gists{/gist_id}","starred_url":"https://api.github.com/users/dlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlang/subscriptions","organizations_url":"https://api.github.com/users/dlang/orgs","repos_url":"https://api.github.com/users/dlang/repos","events_url":"https://api.github.com/users/dlang/events{/privacy}","received_events_url":"https://api.github.com/users/dlang/received_events","type":"Organization","site_admin":false},"repo":{"id":1257084,"name":"phobos","full_name":"dlang/phobos","owner":{"login":"dlang","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/dlang","html_url":"https://github.com/dlang","followers_url":"https://api.github.com/users/dlang/followers","following_url":"https://api.github.com/users/dlang/following{/other_user}","gists_url":"https://api.github.com/users/dlang/gists{/gist_id}","starred_url":"https://api.github.com/users/dlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlang/subscriptions","organizations_url":"https://api.github.com/users/dlang/orgs","repos_url":"https://api.github.com/users/dlang/repos","events_url":"https://api.github.com/users/dlang/events{/privacy}","received_events_url":"https://api.github.com/users/dlang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dlang/phobos","description":"The standard library of the D programming language","fork":false,"url":"https://api.github.com/repos/dlang/phobos","forks_url":"https://api.github.com/repos/dlang/phobos/forks","keys_url":"https://api.github.com/repos/dlang/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dlang/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dlang/phobos/teams","hooks_url":"https://api.github.com/repos/dlang/phobos/hooks","issue_events_url":"https://api.github.com/repos/dlang/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/dlang/phobos/events","assignees_url":"https://api.github.com/repos/dlang/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/dlang/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/dlang/phobos/tags","blobs_url":"https://api.github.com/repos/dlang/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dlang/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dlang/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/dlang/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dlang/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/dlang/phobos/languages","stargazers_url":"https://api.github.com/repos/dlang/phobos/stargazers","contributors_url":"https://api.github.com/repos/dlang/phobos/contributors","subscribers_url":"https://api.github.com/repos/dlang/phobos/subscribers","subscription_url":"https://api.github.com/repos/dlang/phobos/subscription","commits_url":"https://api.github.com/repos/dlang/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/dlang/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/dlang/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/dlang/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/dlang/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/dlang/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dlang/phobos/merges","archive_url":"https://api.github.com/repos/dlang/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dlang/phobos/downloads","issues_url":"https://api.github.com/repos/dlang/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/dlang/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/dlang/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/dlang/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dlang/phobos/labels{/name}","releases_url":"https://api.github.com/repos/dlang/phobos/releases{/id}","deployments_url":"https://api.github.com/repos/dlang/phobos/deployments","created_at":"2011-01-15T07:00:06Z","updated_at":"2016-12-08T08:32:05Z","pushed_at":"2016-12-10T15:24:47Z","git_url":"git://github.com/dlang/phobos.git","ssh_url":"git@github.com:dlang/phobos.git","clone_url":"https://github.com/dlang/phobos.git","svn_url":"https://github.com/dlang/phobos","homepage":"dlang.org/phobos","size":78467,"stargazers_count":760,"watchers_count":760,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":526,"mirror_url":null,"open_issues_count":82,"forks":526,"open_issues":82,"watchers":760,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dlang/phobos/pulls/4927"},"html":{"href":"https://github.com/dlang/phobos/pull/4927"},"issue":{"href":"https://api.github.com/repos/dlang/phobos/issues/4927"},"comments":{"href":"https://api.github.com/repos/dlang/phobos/issues/4927/comments"},"review_comments":{"href":"https://api.github.com/repos/dlang/phobos/pulls/4927/comments"},"review_comment":{"href":"https://api.github.com/repos/dlang/phobos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dlang/phobos/pulls/4927/commits"},"statuses":{"href":"https://api.github.com/repos/dlang/phobos/statuses/1c35ce0516cf75452bb027f75dbbeefc04efdd97"}}}}
{"actor":{"display_login":"andralex"}}