This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.
alignment_of
Section: 21.3.5.4 [meta.unary.prop] Status: C++11 Submitter: Niels Dekker Opened: 2009-06-01 Last modified: 2016-01-28
Priority: Not Prioritized
View other active issues in [meta.unary.prop].
View all other issues in [meta.unary.prop].
View all issues with C++11 status.
Discussion:
The alignment_of
template is no longer necessary, now that the
core language will provide alignof
. Scott Meyers raised this
issue at comp.std.c++,
C++0x: alignof vs. alignment_of,
May 21, 2009. In a reply, Daniel Krügler pointed out that
alignof
was added to the working paper after
alignment_of
. So it appears that alignment_of
is only
part of the current Working Draft
(N2857)
because it is in TR1.
Having both alignof
and alignment_of
would cause
unwanted confusion. In general, I think TR1 functionality should not be
brought into C++0x if it is entirely redundant with other C++0x language
or library features.
[ 2009-11-16 Chris adds: ]
I would like to suggest the following new wording for this issue, based on recent discussions. Basically this doesn't delete
alignment_of
, it just makes it clear that it is just a wrapper foralignof
. This deletes the first part of the proposed resolution, changes the second part by leaving inalignof(T)
but changing the precondition and leaves the 3rd part unchanged.Suggested Resolution:
Change the first row of Table 44 ("Type property queries"), from Type properties 21.3.5.4 [meta.unary.prop]:
Table 44 — Type property queries template <class T> struct alignment_of;
alignof(T)
.
Precondition:T
shall be a complete type, a reference type, or an array of unknown bound, but shall not be a function type or (possibly cv-qualified)void
.alignof(T)
shall be definedChange text in Table 51 ("Other transformations"), from Other transformations 21.3.8.7 [meta.trans.other], as follows:
Table 51 — Other transformations … aligned_storage;
Len
shall not be zero.Align
shall be equal tofor some type
alignment_of<T>::valuealignof(T)T
or to default-alignment.…
[ 2010-01-30 Alisdair proposes that Chris' wording be moved into the proposed wording section and tweaks it on the way. ]
Original proposed wording saved here:
Remove from Header <type_traits> synopsis 21.3.3 [meta.type.synop]:
template <class T> struct alignment_of;Remove the first row of Table 44 ("Type property queries"), from Type properties 21.3.5.4 [meta.unary.prop]:
Table 44 — Type property queries template <class T> struct alignment_of;
alignof(T)
.
Precondition:T
shall be a complete type, a reference type, or an array of unknown bound, but shall not be a function type or (possibly cv-qualified)void
.Change text in Table 51 ("Other transformations"), from Other transformations 21.3.8.7 [meta.trans.other], as follows:
Table 51 — Other transformations … aligned_storage;
Len
shall not be zero. Align shall be equal tofor some type
alignment_of<T>::valuealignof(T)T
or to default-alignment.…
[ 2010-01-30 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]
Proposed resolution:
Change the first row of Table 43 ("Type property queries"), from Type properties 21.3.5.4 [meta.unary.prop]:
Table 43 — Type property queries template <class T> struct alignment_of;
alignof(T)
.
Precondition:T
shall be a complete type, a reference type, or an array of unknown bound, but shall not be a function type or (possibly cv-qualified)void
.alignof(T)
is a valid expression (7.6.2.6 [expr.alignof])
Change text in Table 51 ("Other transformations"), from Other transformations 21.3.8.7 [meta.trans.other], as follows:
Table 51 — Other transformations … aligned_storage;
Len
shall not be zero.Align
shall be equal tofor some type
alignment_of<T>::valuealignof(T)T
or to default-alignment.…