<div class="gmail_quote">2009/5/6  <span dir="ltr">&lt;<a href="mailto:dariomt@gmail.com">dariomt@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi list,<br><br>In &#39;classic&#39; C++ style I have signalled optional parameters in a function with pointers that might be null (I wouldn&#39;t like to create overloads for all possible combination of existing and non-existing parameters) e.g.<br>

<br>// p1 is mandatory, p2, p3 and p4 are optional<br>void f(const Param1&amp; p1, const Param2* p2, const Param3* p3, const Param4* p4);<br><br>And call it <br>Param1p1; Param2 p2; Param4 p4;<br>f(p1, &amp;p2, 0, &amp;p4);<br>

<br>I thought I could use boost::optional like this<br><br>void f(const Param1&amp; p1, const boost::optional&lt;Param2&gt; &amp; p2, const boost::optional&lt;Param3&gt; p3, const boost::optional&lt;Param4&gt; &amp; p4);<br>

<br>And call it <br>
Param1p1; Param2 p2; Param4 p4;<br>
f(p1, boost::optional&lt;Param2&gt;(p2), boost::optional&lt;Param3&gt;(), boost::optional&lt;Param4&gt;(p4) );<br>
</blockquote><div><br>It&#39;s less efficient, because all arguments will be copied. It&#39;s also more typing, longer compilation times and more code generated.<br> </div></div>Roman Perepelitsa.<br>

