Flexible interface that supports scaler or arrays

In reply to jnbkeller:

It is difficult to help without knowing how you expect my_data to be used.

I might suggest looking at bit-stream casting(section 6.24.3 in the 1800-2017 LRM) or the streaming operators (section 11.4.14) to reformat the data as needed.