{"action":"created","issue":{"url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/697","repository_url":"https://api.github.com/repos/isocpp/CppCoreGuidelines","labels_url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/697/labels{/name}","comments_url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/697/comments","events_url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/697/events","html_url":"https://github.com/isocpp/CppCoreGuidelines/issues/697","id":172834416,"number":697,"title":"ES.50: Don’t cast away const and mutable","user":{"login":"KindDragon","id":224272,"avatar_url":"https://avatars.githubusercontent.com/u/224272?v=3","gravatar_id":"","url":"https://api.github.com/users/KindDragon","html_url":"https://github.com/KindDragon","followers_url":"https://api.github.com/users/KindDragon/followers","following_url":"https://api.github.com/users/KindDragon/following{/other_user}","gists_url":"https://api.github.com/users/KindDragon/gists{/gist_id}","starred_url":"https://api.github.com/users/KindDragon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KindDragon/subscriptions","organizations_url":"https://api.github.com/users/KindDragon/orgs","repos_url":"https://api.github.com/users/KindDragon/repos","events_url":"https://api.github.com/users/KindDragon/events{/privacy}","received_events_url":"https://api.github.com/users/KindDragon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-23T23:52:40Z","updated_at":"2016-08-24T07:29:14Z","closed_at":null,"body":"> ES.50: Don’t cast away const\r\n> Reason\r\n> \r\n> It makes a lie out of const. Note\r\n> \r\n> Usually the reason to “cast away const” is to allow the updating of some transient information of an otherwise immutable object. Examples are caching, memoization, and precomputation. Such examples are often handled as well or better using **mutable** or an indirection than with a const_cast.\r\n\r\nShouldn't only thread safe class members marked as mutable?\r\n\r\n[You Don’t Know const and mutable](http://channel9.msdn.com/posts/C-and-Beyond-2012-Herb-Sutter-You-dont-know-blank-and-blank) @hsutter "},"comment":{"url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/comments/241980096","html_url":"https://github.com/isocpp/CppCoreGuidelines/issues/697#issuecomment-241980096","issue_url":"https://api.github.com/repos/isocpp/CppCoreGuidelines/issues/697","id":241980096,"user":{"login":"Amaroker","id":20886724,"avatar_url":"https://avatars.githubusercontent.com/u/20886724?v=3","gravatar_id":"","url":"https://api.github.com/users/Amaroker","html_url":"https://github.com/Amaroker","followers_url":"https://api.github.com/users/Amaroker/followers","following_url":"https://api.github.com/users/Amaroker/following{/other_user}","gists_url":"https://api.github.com/users/Amaroker/gists{/gist_id}","starred_url":"https://api.github.com/users/Amaroker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Amaroker/subscriptions","organizations_url":"https://api.github.com/users/Amaroker/orgs","repos_url":"https://api.github.com/users/Amaroker/repos","events_url":"https://api.github.com/users/Amaroker/events{/privacy}","received_events_url":"https://api.github.com/users/Amaroker/received_events","type":"User","site_admin":false},"created_at":"2016-08-24T07:29:14Z","updated_at":"2016-08-24T07:29:14Z","body":"What do you mean with \"thread safe class members\"?\r\n\r\nYou only need to mark a member variable mutable if you will modify it in a const member function.\r\n\r\nThen, to ensure thread safety, you need to protect the mutable member with a mutex (unless it's atomic).\r\n\r\nThe member variable itself (non-public of course) doesn't need to be thread safe. The important thing is that only one thread at a time can have access to it."}}
{"actor":{"display_login":"Amaroker"}}