{"action":"created","issue":{"url":"https://api.github.com/repos/YSRKEN/KanColleSimulator_KAI/issues/9","repository_url":"https://api.github.com/repos/YSRKEN/KanColleSimulator_KAI","labels_url":"https://api.github.com/repos/YSRKEN/KanColleSimulator_KAI/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/YSRKEN/KanColleSimulator_KAI/issues/9/comments","events_url":"https://api.github.com/repos/YSRKEN/KanColleSimulator_KAI/issues/9/events","html_url":"https://github.com/YSRKEN/KanColleSimulator_KAI/issues/9","id":137126569,"number":9,"title":"WeaponDB::Getの実装について","user":{"login":"yumetodo","id":10869046,"avatar_url":"https://avatars.githubusercontent.com/u/10869046?v=3","gravatar_id":"","url":"https://api.github.com/users/yumetodo","html_url":"https://github.com/yumetodo","followers_url":"https://api.github.com/users/yumetodo/followers","following_url":"https://api.github.com/users/yumetodo/following{/other_user}","gists_url":"https://api.github.com/users/yumetodo/gists{/gist_id}","starred_url":"https://api.github.com/users/yumetodo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yumetodo/subscriptions","organizations_url":"https://api.github.com/users/yumetodo/orgs","repos_url":"https://api.github.com/users/yumetodo/repos","events_url":"https://api.github.com/users/yumetodo/events{/privacy}","received_events_url":"https://api.github.com/users/yumetodo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-02-29T01:57:39Z","updated_at":"2016-02-29T05:46:08Z","closed_at":null,"body":"現在、\r\n\r\n```cpp\r\nWeaponDB::WeaponDB() {\r\n\t//前略\r\n\t// ダミーデータを代入する\r\n\thash_[-1] = Weapon();\r\n}\r\n\r\nWeapon WeaponDB::Get(const int id) const{\r\n\tif (hash_.find(id) != hash_.end()) {\r\n\t\treturn hash_.at(id);\r\n\t}\r\n\telse {\r\n\t\treturn hash_.at(-1);\r\n\t}\r\n}\r\n```\r\n\r\nのようになっているがこれは冗長で良くない。\r\n\r\n```cpp\r\nWeaponDB::WeaponDB() {\r\n\t//前略\r\n\t// ダミーデータを代入する\r\n\t//hash_[-1] = Weapon();\r\n}\r\n\r\nWeapon WeaponDB::Get(const int id) const{\r\n\treturn hash_.at(id);\r\n}\r\n```\r\n\r\nとするか\r\n\r\n```cpp\r\nWeaponDB::WeaponDB() {\r\n\t//前略\r\n\t// ダミーデータを代入する\r\n\t//hash_[-1] = Weapon();//要らない\r\n}\r\n\r\nWeapon WeaponDB::Get(const int id) const{\r\n\ttry{\r\n\t\treturn hash_.at(id);\r\n\t\r\n\tcatch(...){\r\n\t\treturn {};\r\n\t}\r\n}\r\n```\r\nとするべきではないか？(後者は``Weapon``のデフォルトコンストラクタがnoexceptにできないのでnoexceptをつけられない、 #8 参照)"},"comment":{"url":"https://api.github.com/repos/YSRKEN/KanColleSimulator_KAI/issues/comments/190055326","html_url":"https://github.com/YSRKEN/KanColleSimulator_KAI/issues/9#issuecomment-190055326","issue_url":"https://api.github.com/repos/YSRKEN/KanColleSimulator_KAI/issues/9","id":190055326,"user":{"login":"yumetodo","id":10869046,"avatar_url":"https://avatars.githubusercontent.com/u/10869046?v=3","gravatar_id":"","url":"https://api.github.com/users/yumetodo","html_url":"https://github.com/yumetodo","followers_url":"https://api.github.com/users/yumetodo/followers","following_url":"https://api.github.com/users/yumetodo/following{/other_user}","gists_url":"https://api.github.com/users/yumetodo/gists{/gist_id}","starred_url":"https://api.github.com/users/yumetodo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yumetodo/subscriptions","organizations_url":"https://api.github.com/users/yumetodo/orgs","repos_url":"https://api.github.com/users/yumetodo/repos","events_url":"https://api.github.com/users/yumetodo/events{/privacy}","received_events_url":"https://api.github.com/users/yumetodo/received_events","type":"User","site_admin":false},"created_at":"2016-02-29T05:46:08Z","updated_at":"2016-02-29T05:46:08Z","body":"@YSRKEN pushしました、確認してcloseお願いします"}}