<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Incidentally, you may be interested in the Constrained Value library (<a href="http://student.agh.edu.pl/%7Ekawulak/constrained_value/index.html" target="_blank">http://student.agh.edu.pl/~kawulak/constrained_value/index.html</a>)<br>

</blockquote><div><br>I like that idea.<br><br>I quite like the idea of things like an 8bit number that stores values between 0 and  1.<br><br>I like the idea of a number type, that can store numbers in all sorts of forms, an example could be a &quot;8bit integer / 8bit integer&quot; or &quot;4bit float&quot; or whatever, you could instruct it with methods to do things such as. Have a scale defining it&#39;s limits and possibly also set limits, store 2 numbers in 3 bits. Store a value in a number of forms so that it is always quick to access for different uses or have it store it in the most specially efficient form for the value, have a number that expanded until a certain number of decimal places was reached, or forever, or all sorts of other related things.<br>

<br>I have some idea about a possible way to represent the expandable number in binary as well.<br><br>At least in C++ I would expect this to have such a performance overhead as to make it not worth it even trying to implement though, I guess I don&#39;t much like lexical casting automatically or using the cast syntax, prefer .toString() type methods, but especially between numerical types where it seems like it&#39;s always about fundamentally the same thing, a number.<br>

<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
&gt; I do appreciate there are different views here, however if one has <br>
&gt; chosen boost::any already then they already know what they want, <br>
&gt; especially given the stuff in std. Suggesting that because you can <br>
&gt; cause an error an error could unexpectedly occur when you pass <br>
&gt; unknown objects into an unknown method in a non sensible example <br>
&gt; that wouldn&#39;t happen isn&#39;t helpful.<br>
<br></div>
You have to appreciate where we are coming from. Your original post had code where you tried to pass the result of a runtime method as a template parameter.<br>
This suggests you are not hugely familiar with C++ and perhaps Boost.Any, so people naturally ponder whether Boost.Any really is the right choice (often it isn&#39;t) and try to help by making sure the OP has heard about the alternatives.<br>

</blockquote><div><br>Your right, I am fairly new to C++.<br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
&gt; The documentation says that for boost::any a program doesn&#39;t crash<br>

&gt; if you try and cast an any into a type it was not set as, it gives a<br>
&gt; null instead.<br>
<br></div>
Actually, If try to retrieve a pointer to the type, it would return a null, if you tried to retrieve a value, it would throw bad_any_cast.</blockquote><div><br>Thanks.<br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div class="im">&gt; For crashing on stream insertion when it&#39;s contents can&#39;t be <br>
&gt; inserted vs giving an error that will stop the program more safely <br>
&gt; and tell the coder what went wrong, I think the latter is more <br>
&gt; desirable, unless there is a significant performance difference in <br>
&gt; which case either one is valid.<br>
<br></div>
Right, if you went down a has_operator_stream route, you could throw an exception instead of blowing the stack.<br>
<br>
Feel free to offer a patch along those lines if you want, but it opens up a can worms. If operator&lt;&lt;, why not operator+, or member foo() etc... I am sceptical that the maintainer would accept it.<br></blockquote><div>

<br>Does adobe::polly offer a way to call methods on the anys content without unwrapping it? Could this be done generically for any method (I know there would be type/method safety issues)?<br><br>I&#39;m using Peters version. My stuff is ambitious but higher level, I can&#39;t write things like this.<br>

<br>It would possibly make a good case to have two versions of boost::any if the generic methods could be implemented, would also close the can of worms, nothing would ever need to be added to it again.<br><br>Maybe I have overlooked that a stream and other such things are probably not proper methods at any level and so there are a few worms, but a finite number.<br>

</div></div>

