gul-cpp / gul14

General Utility Library for C++14
https://gul14.info/
GNU Lesser General Public License v2.1
2 stars 1 forks source link

Add initialization helper for std::array #53

Closed soerengrunewald closed 7 months ago

soerengrunewald commented 1 year ago

I have found this a while ago as merge request in the dxvk project. It simplifies the initialization of std::array, as one does not have to specify the actual array size. Instead we let the compiler figure it out.

There something similar available with std::experimental::make_array.

Finii commented 1 year ago

Tests trigger :tada: @alt-graph ;)

Finii commented 1 year ago

This is missing unit tests :laughing:

And documentation :rofl:

alt-graph commented 1 year ago

Nice little helper! I wouldn't create another header for it, though. Maybe we can stuff it into utility.h or traits.h? Ah yes, tests and documentation... :) Don't know about the copyright situation. Can we just rewrite it from scratch? Otherwise we need an entry in our copyright list.

alt-graph commented 1 year ago

Maybe make_array() would also be a possible name.

Finii commented 11 months ago

No answer from author within 4 months, so closing...

Maybe use this implementation from cppreference:

image

Finii commented 11 months ago

Maybe make_array() would also be a possible name.

image

to_array would be the backport.

soerengrunewald commented 7 months ago

I played a bit around in the attempt to backport std::to_array bit. It works only with primitive types and strings. More complex types make trouble, so I will close this MR for now.