<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 5/4/2016 4:30 PM, Kurt Schwehr
wrote:<br>
<br>
</div>
<blockquote
cite="mid:CACmBxyvZVV26DJVRCUKpBcLpJ3oLUTCrCqyPjrM=z0RwnbdmFQ@mail.gmail.com"
type="cite"><span
id="docs-internal-guid-0b509e3e-7dde-87d0-f7e4-b6ef1bd7d820"><description
of approach using std::vector><br>
</span></blockquote>
<br>
<blockquote
cite="mid:CACmBxyvZVV26DJVRCUKpBcLpJ3oLUTCrCqyPjrM=z0RwnbdmFQ@mail.gmail.com"
type="cite"><span
id="docs-internal-guid-0b509e3e-7dde-87d0-f7e4-b6ef1bd7d820">
<p dir="ltr"
style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Drawbacks:</span></p>
<br>
<ul style="margin-top:0pt;margin-bottom:0pt">
<li dir="ltr"
style="list-style-type:disc;font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:transparent">
<p dir="ltr"
style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">It is possible to change the size of the vector later on in the code</span></p>
</li>
<li dir="ltr"
style="list-style-type:disc;font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:transparent">
<p dir="ltr"
style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Vector has some storage overhead and bookkeeping that has to be done (but often the compiler can probably optimize away most of that). TODO: References that explain this?</span></p>
</li>
<li dir="ltr"
style="list-style-type:disc;font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:transparent">
<p dir="ltr"
style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Resizing the array could break anything that was using a C style array pointer to the vector’s data</span></p>
</li>
</ul>
</span></blockquote>
<br>
Drawbacks one and three can be eliminated by deriving a class from
vector that hides resize, so there really is only the single
drawback of storage overhead and bookkeeping, which are often minor.<br>
<br>
Another benefit of the proposed approach is that it makes it less
tempting to use inscrutable pointer tricks for referencing array
entries.<br>
</body>
</html>