Skip to content

Commit

Permalink
talking about 'new' was misleading
Browse files Browse the repository at this point in the history
  • Loading branch information
tvaneerd committed Mar 28, 2017
1 parent 5033bcd commit e33d9a9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions any.md
Expand Up @@ -18,6 +18,7 @@ C++17
</tr>
<tr>
<td valign="top">

<pre lang="cpp">
void * v = ...;
if (v != nullptr) {
Expand All @@ -27,6 +28,7 @@ if (v != nullptr) {
</pre>
</td>
<td valign="top">

<pre lang="cpp">
std::any v = ...;
if (v.has_value()) {
Expand All @@ -36,6 +38,7 @@ if (v.has_value()) {
</pre>
</td>
<td valign="top">

<pre lang="cpp">
std::any v = ...;
if (v.type() == typeid(int)) {
Expand All @@ -61,17 +64,17 @@ C++17
</tr>
<tr>
<td valign="top">

<pre lang="cpp">
// can hold Circles, Squares, Triangles,...
std::vector&lt;Shape *&gt; shapes;
// requires lots of calls to new
</pre>
</td>
<td valign="top">

<pre lang="cpp">
// can hold Circles, Squares, Triangles, ints, strings,...
std::vector&lt;any&gt; things;
// no calls to new
</pre>
</td>
</tr>
Expand Down

0 comments on commit e33d9a9

Please sign in to comment.