{"action":"created","issue":{"url":"https://api.github.com/repos/philippeb8/root_ptr/issues/2","repository_url":"https://api.github.com/repos/philippeb8/root_ptr","labels_url":"https://api.github.com/repos/philippeb8/root_ptr/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/philippeb8/root_ptr/issues/2/comments","events_url":"https://api.github.com/repos/philippeb8/root_ptr/issues/2/events","html_url":"https://github.com/philippeb8/root_ptr/issues/2","id":141138646,"number":2,"title":"Updated allocator test case","user":{"login":"glenfe","id":712180,"avatar_url":"https://avatars.githubusercontent.com/u/712180?v=3","gravatar_id":"","url":"https://api.github.com/users/glenfe","html_url":"https://github.com/glenfe","followers_url":"https://api.github.com/users/glenfe/followers","following_url":"https://api.github.com/users/glenfe/following{/other_user}","gists_url":"https://api.github.com/users/glenfe/gists{/gist_id}","starred_url":"https://api.github.com/users/glenfe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glenfe/subscriptions","organizations_url":"https://api.github.com/users/glenfe/orgs","repos_url":"https://api.github.com/users/glenfe/repos","events_url":"https://api.github.com/users/glenfe/events{/privacy}","received_events_url":"https://api.github.com/users/glenfe/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-16T00:46:34Z","updated_at":"2016-03-21T20:19:35Z","closed_at":"2016-03-21T20:19:35Z","body":"Try and make the following updated test case compile with your current implementation with `root_ptr`:\r\n\r\n```cpp\r\n#include <memory>\r\n\r\nvoid* operator new(std::size_t)\r\n{\r\n    throw 1;\r\n}\r\n\r\nvoid operator delete(void*, std::size_t)\r\n{\r\n    throw 2;\r\n}\r\n\r\ntemplate<class T>\r\nclass Allocator {\r\n    template<class U>\r\n    friend class Allocator;\r\npublic:\r\n    using value_type = T;\r\n    Allocator(int& state1_, int& state2_)\r\n        : state1(state1_),\r\n          state2(state2_) { }\r\n    template<class U>\r\n    Allocator(const Allocator<U>& other)\r\n        : state1(other.state1),\r\n          state2(other.state2) { }\r\n    T* allocate(std::size_t n) {\r\n        if (auto p = std::malloc(sizeof(T) * n)) {\r\n            ++state1;\r\n            return static_cast<T*>(p);\r\n        } else {\r\n            throw std::bad_alloc();\r\n        }\r\n    }\r\n    void deallocate(T* p, std::size_t) {\r\n        std::free(p);\r\n        --state1;\r\n    }\r\n    template<class U, class... Args>\r\n    void construct(U* p, Args&&... args) {\r\n        ::new(p) U(std::forward<Args>(args)...);\r\n        ++state2;\r\n    }\r\n    template<class U>\r\n    void destroy(U* p) {\r\n        p->~U();\r\n        --state2;\r\n    }\r\nprivate:\r\n    int& state1;\r\n    int& state2;\r\n};\r\n\r\nstruct W {\r\n    explicit W(int) { }\r\n    W(const W&) = delete;\r\n    W(W&&) { }\r\n    W& operator=(const W&) = delete;\r\n    W& operator=(W&&) = delete;\r\n};\r\n\r\nstruct U {\r\n    U(W&&) { }\r\n};\r\n\r\nint main()\r\n{\r\n    int n1 = 0, m1 = 0;\r\n    int n2 = 0, m2 = 0;\r\n    {\r\n        std::shared_ptr<U> p1, p2, p3;\r\n        p1 = std::allocate_shared<U>(Allocator<U>(n1, m1), W(1));\r\n        p2 = std::allocate_shared<U>(Allocator<U>(n2, m2), W(2));\r\n        p3 = std::allocate_shared<U>(Allocator<U>(n2, m2), W(3));\r\n        if (n1 != 1 || m1 != 1 || n2 != 2 || m2 != 2) {\r\n            throw 3;\r\n        }\r\n    }\r\n    if (n1 != 0 || m1 != 0 || n2 != 0 || m2 != 0) {\r\n        throw 4;\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/philippeb8/root_ptr/issues/comments/199459040","html_url":"https://github.com/philippeb8/root_ptr/issues/2#issuecomment-199459040","issue_url":"https://api.github.com/repos/philippeb8/root_ptr/issues/2","id":199459040,"user":{"login":"philippeb8","id":13325028,"avatar_url":"https://avatars.githubusercontent.com/u/13325028?v=3","gravatar_id":"","url":"https://api.github.com/users/philippeb8","html_url":"https://github.com/philippeb8","followers_url":"https://api.github.com/users/philippeb8/followers","following_url":"https://api.github.com/users/philippeb8/following{/other_user}","gists_url":"https://api.github.com/users/philippeb8/gists{/gist_id}","starred_url":"https://api.github.com/users/philippeb8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philippeb8/subscriptions","organizations_url":"https://api.github.com/users/philippeb8/orgs","repos_url":"https://api.github.com/users/philippeb8/repos","events_url":"https://api.github.com/users/philippeb8/events{/privacy}","received_events_url":"https://api.github.com/users/philippeb8/received_events","type":"User","site_admin":false},"created_at":"2016-03-21T20:19:35Z","updated_at":"2016-03-21T20:19:35Z","body":"Fixed."}}