Providing tuple-like structured binding access for a class
问题 I'm trying to support tuple-like structured binding access for a class. For simplicity, I'll use the following class in the rest of this post: struct Test { int v = 42; }; (I'm aware that this class supports structured bindings out of the box but let's assume it does not.) To enable tuple-like access to the member of Test , we must specialize std::tuple_size and std::tuple_element : namespace std { template<> struct tuple_size<Test> { static const std::size_t value = 1; }; template<std::size