Allocation Target std :: aligned_storage (stack or heap?)

I tried to make out the addition of TR1, known as aligned_storage. After reading the following documents N2165 , N3190 and N2140 I can’t see an expression in my life in which it clearly describes the structure of the stack or heap of memory used.

I looked at the implementation provided by msvc2010, boost, and gcc, all of which provide a stack based solution based on combining.

In short:

  • Is the type of memory (stack or heap) used by the aligned_storage implementation, or is it always intended for the stack?

  • and, What is a specific document that defines / defines this?

Note. In MSVC10, the following type definition is aligned_storage, in which case aligned_storage is an automatic variable, data is created on the stack (_Val, _Pad):

template<class _Ty, size_t _Len> 
union _Align_type
{   
   // union with size _Len bytes and alignment of _Ty
   _Ty _Val;
   char _Pad[_Len];
};

Note. This is NOT a trivial question. Before sending an answer, try to understand this question.

+5
source share
2 answers

std::aligned_storage<Len, Align>just declares a member of typedef ( type).

The typedef element typemust be a POD type, suitable for use as an uninitialized storage for any object with a size of no more Lenand whose alignment is a dividerAlign

( ++ 0x, N3225, 20.7.6.6 53, TR1, N1836, , ++ 0x Align .)

std::aligned_storage . std::aligned_storage<Len, Align>::type , , .

+12

, (new/malloc) , .

0

All Articles