Title
C++0x does not need alignment_of
Status
c++11
Section
[meta.unary.prop]
Submitter
Niels Dekker

Created on 2009-06-01.00:00:00 last changed 161 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Change the first row of Table 43 ("Type property queries"), from Type properties [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 ([expr.alignof])

Change text in Table 51 ("Other transformations"), from Other transformations [meta.trans.other], as follows:

Table 51 — Other transformations
aligned_storage; Len shall not be zero. Align shall be equal to alignment_of<T>::value alignof(T) for some type T or to default-alignment.
Date: 2010-01-30.00:00:00

[ 2010-01-30 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]

Date: 2010-01-30.00:00:00

[ 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 [meta.type.synop]:

template <class T> struct alignment_of;

Remove the first row of Table 44 ("Type property queries"), from Type properties [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 [meta.trans.other], as follows:

Table 51 — Other transformations
aligned_storage; Len shall not be zero. Align shall be equal to alignment_of<T>::value alignof(T) for some type T or to default-alignment.
Date: 2009-11-16.00:00:00

[ 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 for alignof. This deletes the first part of the proposed resolution, changes the second part by leaving in alignof(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 [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 defined

Change text in Table 51 ("Other transformations"), from Other transformations [meta.trans.other], as follows:

Table 51 — Other transformations
aligned_storage; Len shall not be zero. Align shall be equal to alignment_of<T>::value alignof(T) for some type T or to default-alignment.
Date: 2009-06-01.00:00:00

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.

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-10-21 18:28:33adminsetmessages: + msg863
2010-10-21 18:28:33adminsetmessages: + msg862
2010-10-21 18:28:33adminsetmessages: + msg861
2010-10-21 18:28:33adminsetmessages: + msg860
2009-06-01 00:00:00admincreate