cds  2.3.2
cds::details::aligned_type< T, Alignment > Struct Template Reference

Aligned type. More...

#include <cds/details/aligned_type.h>

Detailed Description

template<typename T, size_t Alignment>
struct cds::details::aligned_type< T, Alignment >

Aligned type.

This meta-algorithm solves compiler problem when you need to declare a type T with alignment equal to another type alignment. For example, the following declaration produces an error in Microsoft Visual Studio 2008 compiler:

typedef double my_double;
typedef __declspec(align( __alignof(my_double))) int aligned_int;

In MS VS, the __declspec(align(N)) construction requires that N must be a integer constant (1, 2, 4 and so on) but not an integer constant expression.

The result of this meta-algo is a type aligned_type<T,Alignment>::type that is T aligned by Alignment. For example, with aligned_type the prevoius example will not generate an error:

typedef double my_double;

and result of this declaration is equivalent to

typedef __declspec(align(8)) int aligned_int;

The Alignment template parameter must be a constant expression and its result must be power of two. The maximum of its value is 1024.

See also align_as


The documentation for this struct was generated from the following file:

cds 2.3.2 Developed by Maxim Khizhinsky aka khizmax and other contributors 2007 - 2017
Autogenerated Sun Dec 31 2017 12:10:35 by Doxygen 1.8.13