{"action":"closed","issue":{"url":"https://api.github.com/repos/pybind/pybind11/issues/249","repository_url":"https://api.github.com/repos/pybind/pybind11","labels_url":"https://api.github.com/repos/pybind/pybind11/issues/249/labels{/name}","comments_url":"https://api.github.com/repos/pybind/pybind11/issues/249/comments","events_url":"https://api.github.com/repos/pybind/pybind11/issues/249/events","html_url":"https://github.com/pybind/pybind11/issues/249","id":161499279,"number":249,"title":"failed to cast std::array to py::array","user":{"login":"timbad","id":8617259,"avatar_url":"https://avatars.githubusercontent.com/u/8617259?v=3","gravatar_id":"","url":"https://api.github.com/users/timbad","html_url":"https://github.com/timbad","followers_url":"https://api.github.com/users/timbad/followers","following_url":"https://api.github.com/users/timbad/following{/other_user}","gists_url":"https://api.github.com/users/timbad/gists{/gist_id}","starred_url":"https://api.github.com/users/timbad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timbad/subscriptions","organizations_url":"https://api.github.com/users/timbad/orgs","repos_url":"https://api.github.com/users/timbad/repos","events_url":"https://api.github.com/users/timbad/events{/privacy}","received_events_url":"https://api.github.com/users/timbad/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-21T17:48:30Z","updated_at":"2016-06-22T07:54:23Z","closed_at":"2016-06-22T07:54:23Z","body":"I want to cast std::array of strings to py::array or list and set it as an attribute of module. How can i do that?\r\n\r\nI tried it the following way, but casting failed:\r\n```C++\r\nvoid init_some_info(py::module &main)\r\n{\r\n    auto m = main.def_submodule(\"arrays_info\");\r\n    std::array<std::string, ARR_TOTAL_NUM> array_names;\r\n    std::copy(std::begin(c_array_names), std::end(c_array_names), std::begin(array_names));\r\n    m.attr(\"d_pool_names\") = py::cast(array_names);\r\n}\r\n```\r\n\r\nAnd tried to define method that returns std::array:\r\n```C++\r\nvoid init_some_info(py::module &main)\r\n{\r\n    auto m = main.def_submodule(\"arrays_info\");\r\n    m.def(\"get_i_pool_names\", [=]() {\r\n        std::array<std::string, ARR_TOTAL_NUM> array_names;\r\n        std::copy(std::begin(c_array_names), std::end(c_array_names), std::begin(array_names));\r\n        return array_names;\r\n      });\r\n}\r\n```\r\nI expected automatic conversion as in example2, but pybind11 failed to convert std::array automatically.\r\n\r\nIs there anything I missed or it is a bug in pybind11?\r\n"}}
{"actor":{"display_login":"timbad"}}