Let's suppose we have this template for a union of a struct and an array of bytes of the same size
template<typename T>
union point {
struct { T x, y; } coord;
static constexpr size_t buffer_size = sizeof(coord);
unsigned char buffer[buffer_size];
};
and we would like to use CTAD and aggregate initialization in client code following to C++17
auto p1 = point { .coord = { 0.1, 0.2 } };
auto p2 = point { .coord = { 1, 2 } };
The compiler expects us a deduction guide for point
type. How it can be defined in case of union type?