
2012/12/18 Nevin Liber <nevin@eviloverlord.com>:
On 17 December 2012 19:39, Adam Wulkiewicz <adam.wulkiewicz@gmail.com>wrote:
Btw, how is data() defined?
According to the latest draft of the standard, n3485 23.3.6.1, it returns a T* (or a const T* for the const member version); this is the same as value_type*.
This of course won't work for a hybrid_vector.
Why not?
I assumed that in the allocated memory the hybrid_vector stores only elements exceeding the static storage. In this case it would store them in two different places - static storage and allocated one. The overall memory wouldn't be continuous. It would work, if after the static storage overflow and the first allocation, elements were moved to the newly allocated memory. I don't know however if this isn't too big penalty.
But then what is the purpose of this method?
To get to the buffer for passing to C routines, usually.
Yes I understand this. My question is regarding the case when data() returns Alloc::pointer (I believe this is the case in MS implementation). Regards, Adam