{"action":"created","comment":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments/28954319","id":28954319,"diff_hunk":"@@ -64,67 +69,18 @@ static if (is(T:Object))\n else\n     alias RefT = T*;\n \n-public:\n-    // Deferred in case we get some language support for checking uniqueness.\n-    version(None)\n-    /**\n-    Allows safe construction of $(D Unique). It creates the resource and\n-    guarantees unique ownership of it (unless $(D T) publishes aliases of\n-    $(D this)).\n-    Note: Nested structs/classes cannot be created.\n-    Params:\n-    args = Arguments to pass to $(D T)'s constructor.\n-    ---\n-    static class C {}\n-    auto u = Unique!(C).create();\n-    ---\n-    */\n-    static Unique!T create(A...)(auto ref A args)\n-    if (__traits(compiles, new T(args)))\n-    {\n-        debug(Unique) writeln(\"Unique.create for \", T.stringof);\n-        Unique!T u;\n-        u._p = new T(args);\n-        return u;\n-    }\n-\n-    /**\n-    Constructor that takes an rvalue.\n-    It will ensure uniqueness, as long as the rvalue\n-    isn't just a view on an lvalue (e.g., a cast).\n-    Typical usage:\n-    ----\n-    Unique!Foo f = new Foo;\n-    ----\n-    */\n-    this(RefT p)\n-    {\n-        debug(Unique) writeln(\"Unique constructor with rvalue\");\n-        _p = p;\n-    }\n-    /**\n-    Constructor that takes an lvalue. It nulls its source.\n-    The nulling will ensure uniqueness as long as there\n-    are no previous aliases to the source.\n-    */\n-    this(ref RefT p)\n-    {\n-        _p = p;\n-        debug(Unique) writeln(\"Unique constructor nulling source\");\n-        p = null;\n-        assert(p is null);\n-    }\n     /**\n     Constructor that takes a $(D Unique) of a type that is convertible to our type.\n \n     Typically used to transfer a $(D Unique) rvalue of derived type to\n     a $(D Unique) of base type.\n+\n     Example:\n     ---\n-    class C : Object {}\n+    class C : Object { }\n \n-    Unique!C uc = new C;\n-    Unique!Object uo = uc.release;\n+    Unique!C uc = unique!C();\n+    Unique!Object uo = move(uc);","path":"std/typecons.d","position":90,"original_position":90,"commit_id":"5a34389f39193907583b450c34e5d50ac168edaf","original_commit_id":"5a34389f39193907583b450c34e5d50ac168edaf","user":{"login":"MartinNowak","id":288976,"avatar_url":"https://avatars.githubusercontent.com/u/288976?v=3","gravatar_id":"","url":"https://api.github.com/users/MartinNowak","html_url":"https://github.com/MartinNowak","followers_url":"https://api.github.com/users/MartinNowak/followers","following_url":"https://api.github.com/users/MartinNowak/following{/other_user}","gists_url":"https://api.github.com/users/MartinNowak/gists{/gist_id}","starred_url":"https://api.github.com/users/MartinNowak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartinNowak/subscriptions","organizations_url":"https://api.github.com/users/MartinNowak/orgs","repos_url":"https://api.github.com/users/MartinNowak/repos","events_url":"https://api.github.com/users/MartinNowak/events{/privacy}","received_events_url":"https://api.github.com/users/MartinNowak/received_events","type":"User","site_admin":false},"body":"Oh, it's actually is supposed to work.","created_at":"2015-04-23T11:21:17Z","updated_at":"2015-04-23T11:21:17Z","html_url":"https://github.com/D-Programming-Language/phobos/pull/3139#discussion_r28954319","pull_request_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3139","_links":{"self":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments/28954319"},"html":{"href":"https://github.com/D-Programming-Language/phobos/pull/3139#discussion_r28954319"},"pull_request":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3139"}}},"pull_request":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3139","id":32525100,"html_url":"https://github.com/D-Programming-Language/phobos/pull/3139","diff_url":"https://github.com/D-Programming-Language/phobos/pull/3139.diff","patch_url":"https://github.com/D-Programming-Language/phobos/pull/3139.patch","issue_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3139","number":3139,"state":"open","locked":false,"title":"Improve std.typecons.Unique","user":{"login":"mrkline","id":493463,"avatar_url":"https://avatars.githubusercontent.com/u/493463?v=3","gravatar_id":"","url":"https://api.github.com/users/mrkline","html_url":"https://github.com/mrkline","followers_url":"https://api.github.com/users/mrkline/followers","following_url":"https://api.github.com/users/mrkline/following{/other_user}","gists_url":"https://api.github.com/users/mrkline/gists{/gist_id}","starred_url":"https://api.github.com/users/mrkline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrkline/subscriptions","organizations_url":"https://api.github.com/users/mrkline/orgs","repos_url":"https://api.github.com/users/mrkline/repos","events_url":"https://api.github.com/users/mrkline/events{/privacy}","received_events_url":"https://api.github.com/users/mrkline/received_events","type":"User","site_admin":false},"body":"Whenever D is brought up to the general programming public, the garbage collector is quickly raised as a point of contention. Regardless of how legitimate or well-informed these concerns are or are not, it would be a massive public relations boon — and great for the language, to boot — if we could trot out a solid set of RAII-based smart pointers for those who prefer to use them. We have a solid start in `std.typecons.Unique` and `std.typecons.RefCounted`. Unfortunately, these seem to be victims of bit rot and compiler bugs of days long gone.\r\n\r\nThis is the first of several pull requests that attempt to clean these up. An overview of the changes in this request is as follows (updated 2015-04-21):\r\n\r\n- `Unique` uses `malloc` and `free` instead of the GC for backing memory storage. Unfortunately this rules out nested types for the time being (as `emplace` cannot set the frame pointer for closures).\r\n\r\n- `std.algorithm.move` is used instead of a special `release` member function. Whether by design or by happy accident, `move` transfers ownership between `Unique` pointers in a very similar manner to C++'s `std::move` with `std::unique_ptr`. Along with being a familiar paradigm to C++ users, using `move` to transfer ownership makes more intuitive sense and builds consistency with the rest of Phobos.\r\n\r\n- With `std.algorithm.move` transferring ownership, `release` is deprecated.\r\n\r\n- `Unique.create` has transformed into a freestanding `unique` function. Regardless of whether or not there is language support for checking uniqueness, a utility function that creates a `Unique`, taking the same arguments as the underlying type's constructor, is extremely useful, as demonstrated by the addition of `make_unique` to C++14.\r\n\r\n- Constructors taking a pointer have been removed, since we now control allocation ourselves.\r\n\r\n- A new method, `get`, returns the underlying pointer, for use in functions and code that do not play a role in the life cycle of the object. Smart pointers are as much about ownership semantics as they are about allocating and freeing memory, and non-owning code should continue to refer to data using a raw pointer or a reference.\r\n\r\nThis pull request is not meant to be merged _prima facie_, but to initiate a dialogue. I strongly believe this is a good step in the right direction and would love to hear commentary from the core devs. Perhaps some of the implementation details need to be hashed out some more, but we can all agree that a stronger showing from the smart pointers in `std.typecons` will only bolster D and Phobos.","created_at":"2015-04-02T16:01:40Z","updated_at":"2015-04-23T11:21:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c01e6daea0909005dc69145b440c195b37a8f45e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3139/commits","review_comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3139/comments","review_comment_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3139/comments","statuses_url":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/5a34389f39193907583b450c34e5d50ac168edaf","head":{"label":"mrkline:better-unique","ref":"better-unique","sha":"5a34389f39193907583b450c34e5d50ac168edaf","user":{"login":"mrkline","id":493463,"avatar_url":"https://avatars.githubusercontent.com/u/493463?v=3","gravatar_id":"","url":"https://api.github.com/users/mrkline","html_url":"https://github.com/mrkline","followers_url":"https://api.github.com/users/mrkline/followers","following_url":"https://api.github.com/users/mrkline/following{/other_user}","gists_url":"https://api.github.com/users/mrkline/gists{/gist_id}","starred_url":"https://api.github.com/users/mrkline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrkline/subscriptions","organizations_url":"https://api.github.com/users/mrkline/orgs","repos_url":"https://api.github.com/users/mrkline/repos","events_url":"https://api.github.com/users/mrkline/events{/privacy}","received_events_url":"https://api.github.com/users/mrkline/received_events","type":"User","site_admin":false},"repo":{"id":30574095,"name":"phobos","full_name":"mrkline/phobos","owner":{"login":"mrkline","id":493463,"avatar_url":"https://avatars.githubusercontent.com/u/493463?v=3","gravatar_id":"","url":"https://api.github.com/users/mrkline","html_url":"https://github.com/mrkline","followers_url":"https://api.github.com/users/mrkline/followers","following_url":"https://api.github.com/users/mrkline/following{/other_user}","gists_url":"https://api.github.com/users/mrkline/gists{/gist_id}","starred_url":"https://api.github.com/users/mrkline/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrkline/subscriptions","organizations_url":"https://api.github.com/users/mrkline/orgs","repos_url":"https://api.github.com/users/mrkline/repos","events_url":"https://api.github.com/users/mrkline/events{/privacy}","received_events_url":"https://api.github.com/users/mrkline/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mrkline/phobos","description":"The standard library of the D programming language","fork":true,"url":"https://api.github.com/repos/mrkline/phobos","forks_url":"https://api.github.com/repos/mrkline/phobos/forks","keys_url":"https://api.github.com/repos/mrkline/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mrkline/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mrkline/phobos/teams","hooks_url":"https://api.github.com/repos/mrkline/phobos/hooks","issue_events_url":"https://api.github.com/repos/mrkline/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/mrkline/phobos/events","assignees_url":"https://api.github.com/repos/mrkline/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/mrkline/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/mrkline/phobos/tags","blobs_url":"https://api.github.com/repos/mrkline/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mrkline/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mrkline/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/mrkline/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mrkline/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/mrkline/phobos/languages","stargazers_url":"https://api.github.com/repos/mrkline/phobos/stargazers","contributors_url":"https://api.github.com/repos/mrkline/phobos/contributors","subscribers_url":"https://api.github.com/repos/mrkline/phobos/subscribers","subscription_url":"https://api.github.com/repos/mrkline/phobos/subscription","commits_url":"https://api.github.com/repos/mrkline/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/mrkline/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/mrkline/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/mrkline/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/mrkline/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/mrkline/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mrkline/phobos/merges","archive_url":"https://api.github.com/repos/mrkline/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mrkline/phobos/downloads","issues_url":"https://api.github.com/repos/mrkline/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/mrkline/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/mrkline/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/mrkline/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mrkline/phobos/labels{/name}","releases_url":"https://api.github.com/repos/mrkline/phobos/releases{/id}","created_at":"2015-02-10T04:02:21Z","updated_at":"2015-04-03T08:20:06Z","pushed_at":"2015-04-21T08:09:19Z","git_url":"git://github.com/mrkline/phobos.git","ssh_url":"git@github.com:mrkline/phobos.git","clone_url":"https://github.com/mrkline/phobos.git","svn_url":"https://github.com/mrkline/phobos","homepage":"dlang.org/phobos","size":39228,"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":"D-Programming-Language:master","ref":"master","sha":"ee161abf43973aa57a7e5ef950613a64ec8df27f","user":{"login":"D-Programming-Language","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/D-Programming-Language","html_url":"https://github.com/D-Programming-Language","followers_url":"https://api.github.com/users/D-Programming-Language/followers","following_url":"https://api.github.com/users/D-Programming-Language/following{/other_user}","gists_url":"https://api.github.com/users/D-Programming-Language/gists{/gist_id}","starred_url":"https://api.github.com/users/D-Programming-Language/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/D-Programming-Language/subscriptions","organizations_url":"https://api.github.com/users/D-Programming-Language/orgs","repos_url":"https://api.github.com/users/D-Programming-Language/repos","events_url":"https://api.github.com/users/D-Programming-Language/events{/privacy}","received_events_url":"https://api.github.com/users/D-Programming-Language/received_events","type":"Organization","site_admin":false},"repo":{"id":1257084,"name":"phobos","full_name":"D-Programming-Language/phobos","owner":{"login":"D-Programming-Language","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/D-Programming-Language","html_url":"https://github.com/D-Programming-Language","followers_url":"https://api.github.com/users/D-Programming-Language/followers","following_url":"https://api.github.com/users/D-Programming-Language/following{/other_user}","gists_url":"https://api.github.com/users/D-Programming-Language/gists{/gist_id}","starred_url":"https://api.github.com/users/D-Programming-Language/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/D-Programming-Language/subscriptions","organizations_url":"https://api.github.com/users/D-Programming-Language/orgs","repos_url":"https://api.github.com/users/D-Programming-Language/repos","events_url":"https://api.github.com/users/D-Programming-Language/events{/privacy}","received_events_url":"https://api.github.com/users/D-Programming-Language/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/D-Programming-Language/phobos","description":"The standard library of the D programming language","fork":false,"url":"https://api.github.com/repos/D-Programming-Language/phobos","forks_url":"https://api.github.com/repos/D-Programming-Language/phobos/forks","keys_url":"https://api.github.com/repos/D-Programming-Language/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/D-Programming-Language/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/D-Programming-Language/phobos/teams","hooks_url":"https://api.github.com/repos/D-Programming-Language/phobos/hooks","issue_events_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/D-Programming-Language/phobos/events","assignees_url":"https://api.github.com/repos/D-Programming-Language/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/D-Programming-Language/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/D-Programming-Language/phobos/tags","blobs_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/D-Programming-Language/phobos/languages","stargazers_url":"https://api.github.com/repos/D-Programming-Language/phobos/stargazers","contributors_url":"https://api.github.com/repos/D-Programming-Language/phobos/contributors","subscribers_url":"https://api.github.com/repos/D-Programming-Language/phobos/subscribers","subscription_url":"https://api.github.com/repos/D-Programming-Language/phobos/subscription","commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/D-Programming-Language/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/D-Programming-Language/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/D-Programming-Language/phobos/merges","archive_url":"https://api.github.com/repos/D-Programming-Language/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/D-Programming-Language/phobos/downloads","issues_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/D-Programming-Language/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/D-Programming-Language/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/D-Programming-Language/phobos/labels{/name}","releases_url":"https://api.github.com/repos/D-Programming-Language/phobos/releases{/id}","created_at":"2011-01-15T07:00:06Z","updated_at":"2015-04-23T10:49:57Z","pushed_at":"2015-04-23T10:49:57Z","git_url":"git://github.com/D-Programming-Language/phobos.git","ssh_url":"git@github.com:D-Programming-Language/phobos.git","clone_url":"https://github.com/D-Programming-Language/phobos.git","svn_url":"https://github.com/D-Programming-Language/phobos","homepage":"dlang.org/phobos","size":73779,"stargazers_count":590,"watchers_count":590,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":395,"mirror_url":null,"open_issues_count":70,"forks":395,"open_issues":70,"watchers":590,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3139"},"html":{"href":"https://github.com/D-Programming-Language/phobos/pull/3139"},"issue":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3139"},"comments":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3139/comments"},"review_comments":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3139/comments"},"review_comment":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3139/commits"},"statuses":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/5a34389f39193907583b450c34e5d50ac168edaf"}}}}