dimanche 28 mai 2017

Can the limitations of std::align be checked at compile-time or run-time?

I would like to align a memory region to a specific power-of-two alignment using std::align1.

This will apparently invoke UB if the alignment value isn't a fundamental or extended alignment value. Is there any way to check at compile-time (e.g., a static_assert) or at runtime whether the value I want to use is supported?


1 To be clear, I'm also open to std::alignas or std::aligned_storage if they are more flexible or otherwise allow me to safely check what is supported.

Aucun commentaire:

Enregistrer un commentaire