3 #ifndef __CDS_DETAILS_TYPE_PADDING_H
4 #define __CDS_DETAILS_TYPE_PADDING_H
6 namespace cds { namespace details {
9 template <typename T, int Align, int Modulo>
10 struct type_padding_helper: public T
15 char _[Align - Modulo] ; // padding
17 type_padding_helper() CDS_NOEXCEPT_( noexcept( T() ))
20 template <typename T, int Align>
21 struct type_padding_helper<T, Align, 0>: public T
27 type_padding_helper() CDS_NOEXCEPT_( noexcept( T()) )
32 /// Automatic alignment type \p T to \p AlignFactor
34 The class adds appropriate bytes to type T that the following condition is true:
36 sizeof( type_padding<T,AlignFactor>::type ) % AlignFactor == 0
38 It is guaranteed that count of padding bytes no more than AlignFactor - 1.
40 \b Applicability: type \p T must not have constructors another that default ctor.
41 For example, \p T may be any POD type.
43 template <typename T, int AlignFactor>
47 typedef type_padding_helper<T, AlignFactor, sizeof(T) % AlignFactor> type;
55 }} // namespace cds::details
56 #endif // #ifndef __CDS_DETAILS_TYPE_PADDING_H