One design alternative for expressing the alignment precondition on the pointer would be to introduce an aligned_pointer_t type (not alias), as in the example currently in the mdspan repository. The type's constructor would take a pointer and impose an alignment precondition on the pointer. This would shift the burden for checking preconditions from the mdspan as a whole, to data_handle_type itself. That way, mdspan itself wouldn't need a system for checking preconditions, yet (from the user's perspective) preconditions would still be checked at mdspan creation time.
LEWG review of P2897R0 (
aligned_accessor
) on 2023/10/10Feedback
aligned_alloc
to create an overaligned allocation, to show thataligned_accessor
exists as part of a systemgcd
converting constructor requirement from Constraint to MandatePlease see also https://github.com/cplusplus/papers/issues/1568 .
Design alternatives
One design alternative for expressing the alignment precondition on the pointer would be to introduce an
aligned_pointer_t
type (not alias), as in the example currently in the mdspan repository. The type's constructor would take a pointer and impose an alignment precondition on the pointer. This would shift the burden for checking preconditions from the mdspan as a whole, todata_handle_type
itself. That way, mdspan itself wouldn't need a system for checking preconditions, yet (from the user's perspective) preconditions would still be checked at mdspan creation time.