title: Static initialization for complex type array
body: <p>I need static array of vectors initialized with custom Allocators in order to store my data (16 bytes each) in external ram. I use <a href="https://howardhinnant.github.io/stack_alloc.html" rel="nofollow noreferrer">Howard Hinnant short alloc</a> to do so, so far so good.</p>
  
  <p>I use GCC and C++14:</p>
  
  <p><strong>Sequencer.h</strong></p>
  
  <pre><code>    using FixedVector = std::vector&lt;SequencerNoteEvent, short_alloc&lt;SequencerNoteEvent, kBytesChunkMax, 4&gt;&gt;;
  
      /* memory pool */
      static char sequencerNoteEvent[2][600] __attribute__((section(".masection")));
  
      /* Declaration des différentes zones pour chaque vecteur */
      static arena&lt;600&gt; arena0 __attribute__((section(".masection")));
      static arena&lt;600&gt; arena1 __attribute__((section(".masection")));
  
       /* Declaration des Vectors utilisants les pools */
      static FixedVector v0 __attribute__((section(".masection")));
      static FixedVector v1 __attribute__((section(".masection")));
  </code></pre>
  
  <p><strong>Sequencer.cpp</strong></p>
  
  <pre><code>// ---------------
  // STATIC VARIABLE
  // ---------------
  char Sequencer::sequencerNoteEvent[kMaxChunks][kBytesChunkMax];
  
  arena&lt;kBytesChunkMax&gt; Sequencer::arena0{Sequencer::sequencerNoteEvent[0]};
  FixedVector Sequencer::v0{Sequencer::arena0};
  arena&lt;kBytesChunkMax&gt; Sequencer::arena1{Sequencer::sequencerNoteEvent[1]};
  FixedVector Sequencer::v1{Sequencer::arena1};
  </code></pre>
  
  <p>I started with 2 memory pool, but i need 98304 of them... And i am totally stuck at initializing an array of these.</p>
  
  <p>I tried this :</p>
  
  <p><strong>Sequencer.h</strong></p>
  
  <pre><code>  /* Declaration de la memory pool */
    static char sequencerNoteEvent[2][600] __attribute__((section(".masection")));
  
    static arena&lt;600&gt; arenaa[2] __attribute__((section(".masection")));
  
    static FixedVector v[2] __attribute__((section(".masection")));
  
  </code></pre>
  
  <p><strong>Sequencer.cpp</strong></p>
  
  <pre><code>arena&lt;600&gt; Sequencer::arenaa[]{Sequencer::sequencerNoteEvent[0], Sequencer::sequencerNoteEvent[1]};
  FixedVector Sequencer::v[]{Sequencer::arenaa[0], Sequencer::arenaa[1]};
  </code></pre>
  
  <pre><code> error: use of deleted function 'arena&lt;N, alignment&gt;::arena(const arena&lt;N, alignment&gt;&amp;) [with unsigned int N = 600; unsigned int alignment = 4]'
   arena&lt;kBytesChunkMax&gt; Sequencer::arenaa[]{Sequencer::sequencerNoteEvent[0], Sequencer::sequencerNoteEvent[1]};
  </code></pre>
  
  <p>and if i allow the copy constructor (which is very likely to be a bad idea)</p>
  
  <pre><code>error: conversion from 'arena&lt;600&gt;' to non-scalar type 'pyrapro::FixedVector' {aka 'std::vector&lt;pyrapro::SequencerNoteEvent, short_alloc&lt;pyrapro::SequencerNoteEvent, 600, 4&gt; &gt;'} requested
   FixedVector Sequencer::v[]{Sequencer::arenaa[0], Sequencer::arenaa[1]};
  </code></pre>
  
  <p>Does someone have any clue of another way to initialize this ?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thanks a lot for your answer !
  Actually i need to instantiate my vectors with custom allocators (short_alloc which redirect to arena in my case). So i need them to be constructed with an arena. Each arena stores and allocate an array in an external ram memory and short_alloc is the custom allocator itself which meets the requirements of the standard. </p>
  
  <pre><code>short_alloc(arena_type&amp; a) noexcept : a_(a) {}
  </code></pre>
  
  <p>Unless i can change the allocator of a vector once it has already been constructed i don't see any other solution.</p>
  
  <p>The move constructor in arena solved part of my issue, i still have :</p>
  
  <pre><code>error: conversion from 'arena&lt;600&gt;' to non-scalar type 'pyrapro::FixedVector' {aka 'std::vector&lt;pyrapro::SequencerNoteEvent, short_alloc&lt;pyrapro::SequencerNoteEvent, 600, 4&gt; &gt;'} requested
  </code></pre>
  
  <p>When i do this :</p>
  
  <pre><code>FixedVector Sequencer::v0{Sequencer::arena0};
  </code></pre>
  
  <p>i calls at initialization short_alloc(arena_type&amp; a) which is fine. Why i am unable to do this multiple times ?</p>
  
  <p>Of course if someone has an idea avoiding this huge initializer_list i am listening !</p>
  
  <p>I tried to set the arena reference in short_alloc classes later with no success so far. References can't be null, i don't want to change all of this code i didn't write with pointers and init the FixedVectors with a reference to a dummy arena leads to the same initial issue. </p>
  
  <p>Thanks,</p>