{"action":"created","issue":{"url":"https://api.github.com/repos/simbody/simbody/issues/426","labels_url":"https://api.github.com/repos/simbody/simbody/issues/426/labels{/name}","comments_url":"https://api.github.com/repos/simbody/simbody/issues/426/comments","events_url":"https://api.github.com/repos/simbody/simbody/issues/426/events","html_url":"https://github.com/simbody/simbody/pull/426","id":100692133,"number":426,"title":"Add ResetOnCopy<T> and ReinitOnCopy<T> mixins","user":{"login":"sherm1","id":4088016,"avatar_url":"https://avatars.githubusercontent.com/u/4088016?v=3","gravatar_id":"","url":"https://api.github.com/users/sherm1","html_url":"https://github.com/sherm1","followers_url":"https://api.github.com/users/sherm1/followers","following_url":"https://api.github.com/users/sherm1/following{/other_user}","gists_url":"https://api.github.com/users/sherm1/gists{/gist_id}","starred_url":"https://api.github.com/users/sherm1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sherm1/subscriptions","organizations_url":"https://api.github.com/users/sherm1/orgs","repos_url":"https://api.github.com/users/sherm1/repos","events_url":"https://api.github.com/users/sherm1/events{/privacy}","received_events_url":"https://api.github.com/users/sherm1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":26,"created_at":"2015-08-13T05:19:49Z","updated_at":"2015-08-14T22:04:56Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/simbody/simbody/pulls/426","html_url":"https://github.com/simbody/simbody/pull/426","diff_url":"https://github.com/simbody/simbody/pull/426.diff","patch_url":"https://github.com/simbody/simbody/pull/426.patch"},"body":"Add ResetOnCopy<T> and ReinitOnCopy<T> mixins. These are used on data members to provide resetting to default values on copy construction or copy assignment, or reinitialization to specified values.\r\nThese can be used on built-in types, pointers, containers, smart pointers, Simbody resource index objects, and almost anything else. (I don't know how to make them work with C array types though.)\r\n\r\nAlso:\r\n- Added a clear() method to unique index types.\r\n- Added templates that define all relational operators when given only operator==() and operator<()."},"comment":{"url":"https://api.github.com/repos/simbody/simbody/issues/comments/131250951","html_url":"https://github.com/simbody/simbody/pull/426#issuecomment-131250951","issue_url":"https://api.github.com/repos/simbody/simbody/issues/426","id":131250951,"user":{"login":"sherm1","id":4088016,"avatar_url":"https://avatars.githubusercontent.com/u/4088016?v=3","gravatar_id":"","url":"https://api.github.com/users/sherm1","html_url":"https://github.com/sherm1","followers_url":"https://api.github.com/users/sherm1/followers","following_url":"https://api.github.com/users/sherm1/following{/other_user}","gists_url":"https://api.github.com/users/sherm1/gists{/gist_id}","starred_url":"https://api.github.com/users/sherm1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sherm1/subscriptions","organizations_url":"https://api.github.com/users/sherm1/orgs","repos_url":"https://api.github.com/users/sherm1/repos","events_url":"https://api.github.com/users/sherm1/events{/privacy}","received_events_url":"https://api.github.com/users/sherm1/received_events","type":"User","site_admin":false},"created_at":"2015-08-14T22:04:56Z","updated_at":"2015-08-14T22:04:56Z","body":"> Might be nice to have an alias using NullOnCopy<T> = ResetOnCopy<unique_ptr<T>>.\r\n\r\nI'm reluctant to hide the object ownership consideration. Having it visible could avoid trouble later. Hopefully we'll get used to thinking:\r\n```c++\r\n    ResetOnCopy<double*>           m_thing; // <<<--- RED FLAG, possible leak\r\n    ResetOnCopy<unique_ptr<double> m_thing; // all good here\r\n```\r\n\r\n"}}