<div dir="ltr">TL;DR: SmallVector now chooses a default "N", and we recommend using that default. <div><br></div><div><div>We hope that this will</div><div>- Avoid semi-arbitrary choices for the "N" parameter.</div><div>- Save you extra edit/compile cycles for forgotten "N" parameters.</div><div>- Avoid some of the pathological cases of SmallVector use (like sizeof(SmallVector) becoming excessively large)</div><div></div><div><br></div><div>The programmer's manual has been updated, and now reads</div><div><br></div><div><span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px">In the absence of a well-motivated choice for the number of inlined elements </span><code style="font-family:Consolas,"Deja Vu Sans Mono","Bitstream Vera Sans Mono",monospace;font-size:0.95em;color:rgb(0,0,0)"><span>N</span></code><span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px">, it is recommended to use </span><code style="font-family:Consolas,"Deja Vu Sans Mono","Bitstream Vera Sans Mono",monospace;font-size:0.95em;color:rgb(0,0,0)"><span>SmallVector<T></span></code><span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px"> (that is, omitting the </span><code style="font-family:Consolas,"Deja Vu Sans Mono","Bitstream Vera Sans Mono",monospace;font-size:0.95em;color:rgb(0,0,0)"><span>N</span></code><span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px">). This will choose a default number of inlined elements reasonable for allocation on the stack (for example, trying to keep </span><code style="font-family:Consolas,"Deja Vu Sans Mono","Bitstream Vera Sans Mono",monospace;font-size:0.95em;color:rgb(0,0,0)"><span>sizeof(SmallVector<T>)</span></code><span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px"> around 64 bytes).</span><br><div><div><br></div><div><a href="https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h" target="_blank">https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h</a><br></div></div></div><div><br></div><div>We haven't planned any big refactoring to use the new default, so we are expecting it to catch on organically in new code / code reviews / refactorings.</div><div><br></div><div>Enjoy! :)</div><div><br></div><div>For historical reference: This landed in <a href="https://reviews.llvm.org/D92522" target="_blank">https://reviews.llvm.org/D92522</a> after much <a href="https://groups.google.com/g/llvm-dev/c/Z-VwNCTRGSg/m/fYi0JHhzAwAJ" target="_blank">discussion on the list</a> and an <a href="https://reviews.llvm.org/D90884" target="_blank">earlier attempt at a patch</a> which went back and forth on various ideas, including more general aspirations for SmallVector's evolution. </div><div><br></div><div>-- Sean Silva</div></div></div>