Skip to content

Bind Unnamed Struct #3654

Answered by hellozyemlya
hellozyemlya asked this question in Q&A
Discussion options

You must be logged in to vote

This worked perfectly fine:

struct whatever
{
    struct
    {
        std::string name;
    } unnamed;
}
...
py::class_<decltype(whatever::unnamed)>(m, "unnamed")
    .def_readonly("name", &decltype(whatever::unnamed)::name);

py::class_<whatever>(m, "whatever")
    .def_readonly("unnamed", &whatever::unnamed);

Can we add this example to documentation?

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hellozyemlya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant