Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is no standard way to do that. You could dig into a given implementation and see how to deal with that (although there may not actually be a way), but your trick could fail if your library was changed or updated. Library authors generally don't feel the need to support such uses.</p> <p><code>vector&lt;&gt;</code> is a container class. It isn't a wrapper for a C-style array, although it maintains one internally. Its behavior and performance are specified by the Standard, but not its internals (except that its contents must be stored in contiguous memory). Library authors take advantage of that freedom to make the best implementations they can.</p> <p>Suppose you could assign to the internal pointer. That doubtless points to memory from free store, but it may not point to the beginning of the memory, the return value from <code>new</code> or <code>malloc()</code>. The size of the memory must be at least enough to hold the capacity times the size of the elements, but it may in fact be larger. The <code>vector&lt;&gt;</code> might rely on its contents being part of a specific pool, or allocated and deallocated in a specific way. The allocation may affect other data members of <code>vector&lt;&gt;</code>, such as perhaps a pointer to <code>.end()</code>. In any of these cases, you couldn't manage the memory and variables yourself without knowing the exact implementation.</p> <p>In general, meddling with implementation internals is error-prone and can potentially break, with or without immediately obvious effects, with any change to the library. Nor is it often necessary, or even desirable. Find another way to serialize the vectors.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload