Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are several items I've already discovered that are not written to the standard. For instance, this would not work:</p> <pre><code> struct test { int operator()(int); }; std::cout &lt;&lt; typeid( std::result_of&lt;test(int)&gt;::type ).name() &lt;&lt; std::endl; </code></pre> <p>According to the wikipedia site on C++0x it should. Apparently VS2010 uses the TR1 definition of result_of, which is different from what C++0x will have (based on decltype).</p> <p>Also, this does not work:</p> <pre><code> std::bind&lt;int&gt;([](int i)-&gt;int {return i; }); </code></pre> <p>It fails because calling std::result_of (well, the implementation of it), fails because the lambda type has no result_of typedef. This is of course why you supply the return type to the bind call but apparently it ignores it for some reason and continues to search on its own. The boost version of bind works as expected. For this reason we're continuing to use the boost version of bind in our project.</p> <p>Also, if you'll note on <a href="http://blogs.msdn.com/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx?CommentPosted=true#commentmessage" rel="noreferrer">http://blogs.msdn.com/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx?CommentPosted=true#commentmessage</a> that there's some changes yet to be implemented by VS2010 that will effect lambda expressions. I haven't been able to break them but then I haven't used nested lambdas and probably never will.</p> <p>You should also keep in mind that boost::shared_ptr and std::shared_ptr are incompatible. Not surprising, but you must know this if you intend to use one or the other...I'd recommend not both and we're just going to stick with boost.</p> <p>There's also no declval in VS2010. Easy enough to make though:</p> <p><pre><code> template &lt; typename T &gt; T&amp;&amp; declval(); </pre></code></p> <p>Example of use:</p> <pre><code> template &lt; typename T &gt; struct point { T x,y; }; template &lt; typename T1, typename T2 &gt; point&lt;decltype(declval&lt;T1&gt;() + declval&lt;T2&gt;())&gt; operator + (point&lt;T1&gt; const& lh, point&lt;T2&gt; const& rh) { ... } </code></pre> <p>You'll also note in the page I linked above that I've already discussed with members of the dev team (or the PR part or whatever) that there's a bug in decltype. There's more than just the one I mention so I'll show both:</p> <pre><code> template &lt; typename T1, typename T2 &gt; auto operator + (point&lt;T1&gt; const& lh, point&lt;T2&gt; const& rh) -&gt; point&lt;decltype(lh.x + rh.x)&gt; { ... } point&lt;int&gt; x; point&lt;double&gt; y; point&lt;double&gt; pt = x + y; // fails, operator + returned point&lt;const double&gt; void f(); auto ptr = &f; std::cout &lt;&lt; typeid( decltype(*ptr) ).name() &lt;&lt; std::endl; std::cout &lt;&lt; typeid( decltype(*&f) ).name() &lt;&lt; std::endl; // should output the same thing...outputs void (*)() </code></pre> <p>Also...according to some email exchanges about decltype and result_of, this should work:</p> <pre><code> std::result_of&lt; decltype(f)() &gt;::type x = f(); </code></pre> <p>With my home brewed version of std::result_of that uses decltype this would work if the decltype(f)() expression worked correctly. It does not. Gives some error about function returning a function. You have to use "decltype(&amp;f)()" to make the expression work.</p> <p>So, sure...we're using it. There's some bugs and crap though. The benefits outweigh waiting IMHO. Don't expect your code to be standard when the standard comes out though and future MS compilers may break it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload