Providing Structured Binding Interface for Custom Class

To work with custom classes, we need three things: 1. std::tuple_size 2. get<N> 3. std::tuple_element

You can provide Structured Binding support for a custom class.

To do that you have to define get<N>, std::tuple_size and std::tuple_element specialisations for your type.

For example, if you have a class with three members, but you’d like to expose only its public interface:

Get hands-on with 1200+ tech skills courses.