{"action":"created","comment":{"url":"https://api.github.com/repos/particle-iot/device-os/pulls/comments/357903067","pull_request_review_id":332201429,"id":357903067,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM1NzkwMzA2Nw==","diff_hunk":"@@ -22,12 +22,225 @@\n \n namespace particle {\n \n-template <typename E>\n-constexpr auto to_underlying(E e) noexcept\n-{\n+template <typename T, typename Enable = void>\n+class BitMaskFlags;\n+\n+template<typename T>\n+struct EnableBitwise {\n+    static const bool enable = false;\n+};\n+\n+#define ENABLE_ENUM_CLASS_BITWISE(T) \\\n+template<>                           \\\n+struct EnableBitwise<T> {            \\\n+    static const bool enable = true; \\\n+}\n+\n+template<typename T>\n+class BitMaskFlags<T, typename std::enable_if_t<std::is_enum<T>::value>> {\n+public:\n+    typedef typename std::underlying_type<T>::type ValueType;\n+    \n+    BitMaskFlags();\n+    BitMaskFlags(const T& value);\n+    BitMaskFlags(const BitMaskFlags<T>& flags);\n+\n+    BitMaskFlags<T> operator&(const BitMaskFlags<T>& flags) const;\n+    BitMaskFlags<T>& operator&=(const BitMaskFlags<T>& flags);\n+\n+    BitMaskFlags<T> operator|(const BitMaskFlags<T>& flags) const;\n+    BitMaskFlags<T>& operator|=(const BitMaskFlags<T>& flags);\n+\n+    BitMaskFlags<T> operator^(const BitMaskFlags<T>& flags) const;\n+    BitMaskFlags<T>& operator^=(const BitMaskFlags<T>& flags);\n+\n+    BitMaskFlags<T> operator~() const;\n+\n+    BitMaskFlags<T> operator<<(size_t n) const;\n+    BitMaskFlags<T>& operator<<=(size_t n);\n+    BitMaskFlags<T> operator>>(size_t n) const;\n+    BitMaskFlags<T>& operator>>=(size_t n);\n+\n+    typename std::underlying_type<T>::type value() const;\n+\n+    operator bool() const;\n+    operator ValueType() const;","path":"services/inc/enumclass.h","position":49,"original_position":49,"commit_id":"8583ebc9ca227aede35b045896de50e98e9728c9","original_commit_id":"8583ebc9ca227aede35b045896de50e98e9728c9","user":{"login":"XuGuohui","id":8130559,"node_id":"MDQ6VXNlcjgxMzA1NTk=","avatar_url":"https://avatars0.githubusercontent.com/u/8130559?v=4","gravatar_id":"","url":"https://api.github.com/users/XuGuohui","html_url":"https://github.com/XuGuohui","followers_url":"https://api.github.com/users/XuGuohui/followers","following_url":"https://api.github.com/users/XuGuohui/following{/other_user}","gists_url":"https://api.github.com/users/XuGuohui/gists{/gist_id}","starred_url":"https://api.github.com/users/XuGuohui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XuGuohui/subscriptions","organizations_url":"https://api.github.com/users/XuGuohui/orgs","repos_url":"https://api.github.com/users/XuGuohui/repos","events_url":"https://api.github.com/users/XuGuohui/events{/privacy}","received_events_url":"https://api.github.com/users/XuGuohui/received_events","type":"User","site_admin":false},"body":"What if I remove the `ValueType` operator? Can we still keep the `bool` operator?","created_at":"2019-12-14T07:43:27Z","updated_at":"2019-12-14T07:43:27Z","html_url":"https://github.com/particle-iot/device-os/pull/1978#discussion_r357903067","pull_request_url":"https://api.github.com/repos/particle-iot/device-os/pulls/1978","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/particle-iot/device-os/pulls/comments/357903067"},"html":{"href":"https://github.com/particle-iot/device-os/pull/1978#discussion_r357903067"},"pull_request":{"href":"https://api.github.com/repos/particle-iot/device-os/pulls/1978"}},"in_reply_to_id":355392268},"pull_request":{"url":"https://api.github.com/repos/particle-iot/device-os/pulls/1978","id":347555915,"node_id":"MDExOlB1bGxSZXF1ZXN0MzQ3NTU1OTE1","html_url":"https://github.com/particle-iot/device-os/pull/1978","diff_url":"https://github.com/particle-iot/device-os/pull/1978.diff","patch_url":"https://github.com/particle-iot/device-os/pull/1978.patch","issue_url":"https://api.github.com/repos/particle-iot/device-os/issues/1978","number":1978,"state":"open","locked":false,"title":"Implements bitwise operants for enum class","user":{"login":"XuGuohui","id":8130559,"node_id":"MDQ6VXNlcjgxMzA1NTk=","avatar_url":"https://avatars0.githubusercontent.com/u/8130559?v=4","gravatar_id":"","url":"https://api.github.com/users/XuGuohui","html_url":"https://github.com/XuGuohui","followers_url":"https://api.github.com/users/XuGuohui/followers","following_url":"https://api.github.com/users/XuGuohui/following{/other_user}","gists_url":"https://api.github.com/users/XuGuohui/gists{/gist_id}","starred_url":"https://api.github.com/users/XuGuohui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XuGuohui/subscriptions","organizations_url":"https://api.github.com/users/XuGuohui/orgs","repos_url":"https://api.github.com/users/XuGuohui/repos","events_url":"https://api.github.com/users/XuGuohui/events{/privacy}","received_events_url":"https://api.github.com/users/XuGuohui/received_events","type":"User","site_admin":false},"body":"<details>\r\n  <summary><i>submission notes</i></summary>\r\n\r\n### Problem\r\n\r\nEnum class doesn't provide bitwise operants for type-safety purpose. While for bit mask flags, each bit of it may be a member of an enum class, in which case we need to enable bitwise operants to operate the flag basing on the given enum class.\r\n\r\n### Solution\r\n\r\nIntroduce a class template that uses enum class as the only type argument and has a member, which type is the underlying type of the enum class. The corresponding object can be constructed using one of the enum value and it also provides bitwise operants for operating the object using the enum values.\r\n\r\n### Steps to Test\r\n\r\nN/A\r\n\r\n### Example App\r\n\r\nN/A\r\n\r\n### References\r\n\r\nN/A\r\n\r\n---\r\n\r\n### Completeness\r\n\r\n- [x] User is totes amazing for contributing!\r\n- [x] Contributor has signed CLA ([Info here](https://github.com/spark/firmware/blob/develop/CONTRIBUTING.md))\r\n- [ ] Problem and Solution clearly stated\r\n- [ ] Run unit/integration/application tests on device\r\n- [ ] Added documentation\r\n- [ ] Added to CHANGELOG.md after merging (add links to docs and issues)\r\n","created_at":"2019-12-02T10:42:53Z","updated_at":"2019-12-14T07:43:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a5213a4c6280dcad26ae849cd7dabc122eaa4ba","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":511104719,"node_id":"MDU6TGFiZWw1MTExMDQ3MTk=","url":"https://api.github.com/repos/particle-iot/device-os/labels/feature","name":"feature","color":"5319e7","default":false,"description":null},{"id":279587526,"node_id":"MDU6TGFiZWwyNzk1ODc1MjY=","url":"https://api.github.com/repos/particle-iot/device-os/labels/needs%20review","name":"needs review","color":"fbca04","default":false,"description":null},{"id":1457646507,"node_id":"MDU6TGFiZWwxNDU3NjQ2NTA3","url":"https://api.github.com/repos/particle-iot/device-os/labels/realm/embedded-platform","name":"realm/embedded-platform","color":"ede189","default":false,"description":"Embedded Platform"}],"milestone":null,"commits_url":"https://api.github.com/repos/particle-iot/device-os/pulls/1978/commits","review_comments_url":"https://api.github.com/repos/particle-iot/device-os/pulls/1978/comments","review_comment_url":"https://api.github.com/repos/particle-iot/device-os/pulls/comments{/number}","comments_url":"https://api.github.com/repos/particle-iot/device-os/issues/1978/comments","statuses_url":"https://api.github.com/repos/particle-iot/device-os/statuses/8583ebc9ca227aede35b045896de50e98e9728c9","head":{"label":"particle-iot:feature/enum_template/ch38053","ref":"feature/enum_template/ch38053","sha":"8583ebc9ca227aede35b045896de50e98e9728c9","user":{"login":"particle-iot","id":2348966,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNDg5NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/2348966?v=4","gravatar_id":"","url":"https://api.github.com/users/particle-iot","html_url":"https://github.com/particle-iot","followers_url":"https://api.github.com/users/particle-iot/followers","following_url":"https://api.github.com/users/particle-iot/following{/other_user}","gists_url":"https://api.github.com/users/particle-iot/gists{/gist_id}","starred_url":"https://api.github.com/users/particle-iot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/particle-iot/subscriptions","organizations_url":"https://api.github.com/users/particle-iot/orgs","repos_url":"https://api.github.com/users/particle-iot/repos","events_url":"https://api.github.com/users/particle-iot/events{/privacy}","received_events_url":"https://api.github.com/users/particle-iot/received_events","type":"Organization","site_admin":false},"repo":{"id":8720130,"node_id":"MDEwOlJlcG9zaXRvcnk4NzIwMTMw","name":"device-os","full_name":"particle-iot/device-os","private":false,"owner":{"login":"particle-iot","id":2348966,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNDg5NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/2348966?v=4","gravatar_id":"","url":"https://api.github.com/users/particle-iot","html_url":"https://github.com/particle-iot","followers_url":"https://api.github.com/users/particle-iot/followers","following_url":"https://api.github.com/users/particle-iot/following{/other_user}","gists_url":"https://api.github.com/users/particle-iot/gists{/gist_id}","starred_url":"https://api.github.com/users/particle-iot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/particle-iot/subscriptions","organizations_url":"https://api.github.com/users/particle-iot/orgs","repos_url":"https://api.github.com/users/particle-iot/repos","events_url":"https://api.github.com/users/particle-iot/events{/privacy}","received_events_url":"https://api.github.com/users/particle-iot/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/particle-iot/device-os","description":"Device OS (Firmware) for Particle Devices","fork":false,"url":"https://api.github.com/repos/particle-iot/device-os","forks_url":"https://api.github.com/repos/particle-iot/device-os/forks","keys_url":"https://api.github.com/repos/particle-iot/device-os/keys{/key_id}","collaborators_url":"https://api.github.com/repos/particle-iot/device-os/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/particle-iot/device-os/teams","hooks_url":"https://api.github.com/repos/particle-iot/device-os/hooks","issue_events_url":"https://api.github.com/repos/particle-iot/device-os/issues/events{/number}","events_url":"https://api.github.com/repos/particle-iot/device-os/events","assignees_url":"https://api.github.com/repos/particle-iot/device-os/assignees{/user}","branches_url":"https://api.github.com/repos/particle-iot/device-os/branches{/branch}","tags_url":"https://api.github.com/repos/particle-iot/device-os/tags","blobs_url":"https://api.github.com/repos/particle-iot/device-os/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/particle-iot/device-os/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/particle-iot/device-os/git/refs{/sha}","trees_url":"https://api.github.com/repos/particle-iot/device-os/git/trees{/sha}","statuses_url":"https://api.github.com/repos/particle-iot/device-os/statuses/{sha}","languages_url":"https://api.github.com/repos/particle-iot/device-os/languages","stargazers_url":"https://api.github.com/repos/particle-iot/device-os/stargazers","contributors_url":"https://api.github.com/repos/particle-iot/device-os/contributors","subscribers_url":"https://api.github.com/repos/particle-iot/device-os/subscribers","subscription_url":"https://api.github.com/repos/particle-iot/device-os/subscription","commits_url":"https://api.github.com/repos/particle-iot/device-os/commits{/sha}","git_commits_url":"https://api.github.com/repos/particle-iot/device-os/git/commits{/sha}","comments_url":"https://api.github.com/repos/particle-iot/device-os/comments{/number}","issue_comment_url":"https://api.github.com/repos/particle-iot/device-os/issues/comments{/number}","contents_url":"https://api.github.com/repos/particle-iot/device-os/contents/{+path}","compare_url":"https://api.github.com/repos/particle-iot/device-os/compare/{base}...{head}","merges_url":"https://api.github.com/repos/particle-iot/device-os/merges","archive_url":"https://api.github.com/repos/particle-iot/device-os/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/particle-iot/device-os/downloads","issues_url":"https://api.github.com/repos/particle-iot/device-os/issues{/number}","pulls_url":"https://api.github.com/repos/particle-iot/device-os/pulls{/number}","milestones_url":"https://api.github.com/repos/particle-iot/device-os/milestones{/number}","notifications_url":"https://api.github.com/repos/particle-iot/device-os/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/particle-iot/device-os/labels{/name}","releases_url":"https://api.github.com/repos/particle-iot/device-os/releases{/id}","deployments_url":"https://api.github.com/repos/particle-iot/device-os/deployments","created_at":"2013-03-12T04:42:33Z","updated_at":"2019-12-13T18:37:39Z","pushed_at":"2019-12-13T09:35:03Z","git_url":"git://github.com/particle-iot/device-os.git","ssh_url":"git@github.com:particle-iot/device-os.git","clone_url":"https://github.com/particle-iot/device-os.git","svn_url":"https://github.com/particle-iot/device-os","homepage":"https://www.particle.io/","size":131525,"stargazers_count":915,"watchers_count":915,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":493,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":247,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":493,"open_issues":247,"watchers":915,"default_branch":"develop"}},"base":{"label":"particle-iot:develop","ref":"develop","sha":"b069d564b9cc384fc9264935371e8bc292a4fc1b","user":{"login":"particle-iot","id":2348966,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNDg5NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/2348966?v=4","gravatar_id":"","url":"https://api.github.com/users/particle-iot","html_url":"https://github.com/particle-iot","followers_url":"https://api.github.com/users/particle-iot/followers","following_url":"https://api.github.com/users/particle-iot/following{/other_user}","gists_url":"https://api.github.com/users/particle-iot/gists{/gist_id}","starred_url":"https://api.github.com/users/particle-iot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/particle-iot/subscriptions","organizations_url":"https://api.github.com/users/particle-iot/orgs","repos_url":"https://api.github.com/users/particle-iot/repos","events_url":"https://api.github.com/users/particle-iot/events{/privacy}","received_events_url":"https://api.github.com/users/particle-iot/received_events","type":"Organization","site_admin":false},"repo":{"id":8720130,"node_id":"MDEwOlJlcG9zaXRvcnk4NzIwMTMw","name":"device-os","full_name":"particle-iot/device-os","private":false,"owner":{"login":"particle-iot","id":2348966,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNDg5NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/2348966?v=4","gravatar_id":"","url":"https://api.github.com/users/particle-iot","html_url":"https://github.com/particle-iot","followers_url":"https://api.github.com/users/particle-iot/followers","following_url":"https://api.github.com/users/particle-iot/following{/other_user}","gists_url":"https://api.github.com/users/particle-iot/gists{/gist_id}","starred_url":"https://api.github.com/users/particle-iot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/particle-iot/subscriptions","organizations_url":"https://api.github.com/users/particle-iot/orgs","repos_url":"https://api.github.com/users/particle-iot/repos","events_url":"https://api.github.com/users/particle-iot/events{/privacy}","received_events_url":"https://api.github.com/users/particle-iot/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/particle-iot/device-os","description":"Device OS (Firmware) for Particle Devices","fork":false,"url":"https://api.github.com/repos/particle-iot/device-os","forks_url":"https://api.github.com/repos/particle-iot/device-os/forks","keys_url":"https://api.github.com/repos/particle-iot/device-os/keys{/key_id}","collaborators_url":"https://api.github.com/repos/particle-iot/device-os/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/particle-iot/device-os/teams","hooks_url":"https://api.github.com/repos/particle-iot/device-os/hooks","issue_events_url":"https://api.github.com/repos/particle-iot/device-os/issues/events{/number}","events_url":"https://api.github.com/repos/particle-iot/device-os/events","assignees_url":"https://api.github.com/repos/particle-iot/device-os/assignees{/user}","branches_url":"https://api.github.com/repos/particle-iot/device-os/branches{/branch}","tags_url":"https://api.github.com/repos/particle-iot/device-os/tags","blobs_url":"https://api.github.com/repos/particle-iot/device-os/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/particle-iot/device-os/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/particle-iot/device-os/git/refs{/sha}","trees_url":"https://api.github.com/repos/particle-iot/device-os/git/trees{/sha}","statuses_url":"https://api.github.com/repos/particle-iot/device-os/statuses/{sha}","languages_url":"https://api.github.com/repos/particle-iot/device-os/languages","stargazers_url":"https://api.github.com/repos/particle-iot/device-os/stargazers","contributors_url":"https://api.github.com/repos/particle-iot/device-os/contributors","subscribers_url":"https://api.github.com/repos/particle-iot/device-os/subscribers","subscription_url":"https://api.github.com/repos/particle-iot/device-os/subscription","commits_url":"https://api.github.com/repos/particle-iot/device-os/commits{/sha}","git_commits_url":"https://api.github.com/repos/particle-iot/device-os/git/commits{/sha}","comments_url":"https://api.github.com/repos/particle-iot/device-os/comments{/number}","issue_comment_url":"https://api.github.com/repos/particle-iot/device-os/issues/comments{/number}","contents_url":"https://api.github.com/repos/particle-iot/device-os/contents/{+path}","compare_url":"https://api.github.com/repos/particle-iot/device-os/compare/{base}...{head}","merges_url":"https://api.github.com/repos/particle-iot/device-os/merges","archive_url":"https://api.github.com/repos/particle-iot/device-os/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/particle-iot/device-os/downloads","issues_url":"https://api.github.com/repos/particle-iot/device-os/issues{/number}","pulls_url":"https://api.github.com/repos/particle-iot/device-os/pulls{/number}","milestones_url":"https://api.github.com/repos/particle-iot/device-os/milestones{/number}","notifications_url":"https://api.github.com/repos/particle-iot/device-os/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/particle-iot/device-os/labels{/name}","releases_url":"https://api.github.com/repos/particle-iot/device-os/releases{/id}","deployments_url":"https://api.github.com/repos/particle-iot/device-os/deployments","created_at":"2013-03-12T04:42:33Z","updated_at":"2019-12-13T18:37:39Z","pushed_at":"2019-12-13T09:35:03Z","git_url":"git://github.com/particle-iot/device-os.git","ssh_url":"git@github.com:particle-iot/device-os.git","clone_url":"https://github.com/particle-iot/device-os.git","svn_url":"https://github.com/particle-iot/device-os","homepage":"https://www.particle.io/","size":131525,"stargazers_count":915,"watchers_count":915,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":493,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":247,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":493,"open_issues":247,"watchers":915,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/particle-iot/device-os/pulls/1978"},"html":{"href":"https://github.com/particle-iot/device-os/pull/1978"},"issue":{"href":"https://api.github.com/repos/particle-iot/device-os/issues/1978"},"comments":{"href":"https://api.github.com/repos/particle-iot/device-os/issues/1978/comments"},"review_comments":{"href":"https://api.github.com/repos/particle-iot/device-os/pulls/1978/comments"},"review_comment":{"href":"https://api.github.com/repos/particle-iot/device-os/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/particle-iot/device-os/pulls/1978/commits"},"statuses":{"href":"https://api.github.com/repos/particle-iot/device-os/statuses/8583ebc9ca227aede35b045896de50e98e9728c9"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"XuGuohui"}}