1

Is there a way to write type trait or concept, that can be used to detect if type has a method that can be used in structured binding with particular types? Suppose Q is class in question. I want to get a compile time bool constant that tells me if objects of type Q can be used like so:

Q q;

auto [x1, x2] = q.method();

where x1, x2 are float, and bool respectively.

Aisec Nory
  • 385
  • 1
  • 8
  • 2
    From [structured_binding](https://en.cppreference.com/w/cpp/language/structured_binding), there is 3 cases, array, tuple-like types, and binding to data members. All cases are manageable ([magic_get](https://github.com/apolukhin/magic_get) handles the last). – Jarod42 Nov 30 '21 at 08:47
  • 1
    some non-standard (gnu) can be found here: https://stackoverflow.com/questions/49340829/how-to-write-a-concept-for-structured-bindings – PiotrNycz Nov 30 '21 at 09:19

0 Answers0