{"action":"created","issue":{"url":"https://api.github.com/repos/AinoMegumi/boost_synchronous_communication/issues/2","repository_url":"https://api.github.com/repos/AinoMegumi/boost_synchronous_communication","labels_url":"https://api.github.com/repos/AinoMegumi/boost_synchronous_communication/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/AinoMegumi/boost_synchronous_communication/issues/2/comments","events_url":"https://api.github.com/repos/AinoMegumi/boost_synchronous_communication/issues/2/events","html_url":"https://github.com/AinoMegumi/boost_synchronous_communication/issues/2","id":134277649,"number":2,"title":"accept:供給されたファイル ハンドルが無効です","user":{"login":"AinoMegumi","id":11565880,"avatar_url":"https://avatars.githubusercontent.com/u/11565880?v=3","gravatar_id":"","url":"https://api.github.com/users/AinoMegumi","html_url":"https://github.com/AinoMegumi","followers_url":"https://api.github.com/users/AinoMegumi/followers","following_url":"https://api.github.com/users/AinoMegumi/following{/other_user}","gists_url":"https://api.github.com/users/AinoMegumi/gists{/gist_id}","starred_url":"https://api.github.com/users/AinoMegumi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AinoMegumi/subscriptions","organizations_url":"https://api.github.com/users/AinoMegumi/orgs","repos_url":"https://api.github.com/users/AinoMegumi/repos","events_url":"https://api.github.com/users/AinoMegumi/events{/privacy}","received_events_url":"https://api.github.com/users/AinoMegumi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-17T13:17:30Z","updated_at":"2016-02-20T16:18:02Z","closed_at":null,"body":"Recept側で出ているエラー。\r\nどうすればいいんだろうかと悩んでいます。\r\nacceptorとsocketは\r\n\r\n```cpp:\r\nclass Hoge {\r\n// 関数定義等\r\n}\r\n\r\nvoid func() {\r\n\tHoge hoge = Hoge();\r\n}\r\n ```\r\nこんな感じの書き方ができないから困ってます。"},"comment":{"url":"https://api.github.com/repos/AinoMegumi/boost_synchronous_communication/issues/comments/186636991","html_url":"https://github.com/AinoMegumi/boost_synchronous_communication/issues/2#issuecomment-186636991","issue_url":"https://api.github.com/repos/AinoMegumi/boost_synchronous_communication/issues/2","id":186636991,"user":{"login":"AinoMegumi","id":11565880,"avatar_url":"https://avatars.githubusercontent.com/u/11565880?v=3","gravatar_id":"","url":"https://api.github.com/users/AinoMegumi","html_url":"https://github.com/AinoMegumi","followers_url":"https://api.github.com/users/AinoMegumi/followers","following_url":"https://api.github.com/users/AinoMegumi/following{/other_user}","gists_url":"https://api.github.com/users/AinoMegumi/gists{/gist_id}","starred_url":"https://api.github.com/users/AinoMegumi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AinoMegumi/subscriptions","organizations_url":"https://api.github.com/users/AinoMegumi/orgs","repos_url":"https://api.github.com/users/AinoMegumi/repos","events_url":"https://api.github.com/users/AinoMegumi/events{/privacy}","received_events_url":"https://api.github.com/users/AinoMegumi/received_events","type":"User","site_admin":false},"created_at":"2016-02-20T16:18:02Z","updated_at":"2016-02-20T16:18:02Z","body":"要はどうクラスのメンバー変数として持てばいいかって話なんだけど…。\r\nboost::optionalで持ったら今回の例外がスローされたから…。\r\n\r\n```cpp\r\ntemplate<typename T> T get_data(std::string ip, unsigned short port_num) {\r\n\tboost::asio::io_service io_service;\r\n\tboost::asio::ip::tcp::acceptor acceptor(io_service, boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(ip), port_num));\r\n\tboost::asio::ip::tcp::socket socket(io_service);\r\n\tacceptor.accept(socket);\r\n\tstd::string str;\r\n\tstr.reserve(1024);\r\n\tboost::system::error_code error;\r\n\twhile (error != boost::asio::error::eof) {\r\n\t\tboost::array<char, 1024> buf;\r\n\t\tstd::size_t len = socket.read_some(boost::asio::buffer(buf), error);\r\n\t\tstr.insert(str.end(), buf.data(), buf.data() + len);\r\n\t}\r\n\tstd::istringstream istr(str);\r\n\tboost::archive::binary_iarchive ia(istr);\r\n\tT data;\r\n\tistr >> data;\r\n\treturn data;\r\n}\r\n```\r\n無論これは通るんだけど…。"}}