<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 - Discussions by NorvilleShaggy</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/NorvilleShaggy/Discussions/RSS"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 - Discussions by NorvilleShaggy</title>
		<link>http://channel9.msdn.com/Niners/NorvilleShaggy/Discussions</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Niners/NorvilleShaggy/Discussions</link>
	<language>en</language>
	<pubDate>Sun, 26 May 2013 05:06:40 GMT</pubDate>
	<lastBuildDate>Sun, 26 May 2013 05:06:40 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>0</c9:totalResults>
	<c9:pageCount>0</c9:pageCount>
	<c9:pageSize>0</c9:pageSize>
	<item>
		<title>Tech Off - A moving question</title>
		<description><![CDATA[<p>This function use forward:</p><p>Should it not use move instead?<br><br>I used forward in one of my classes, that also caused a copy so i switch to move which did the desired action.<br><br>Can somebody explain why the code doesn't do the right thing?</p><p><br><pre class="brush: cpp">
    template&lt;class _Other1,
        class _Other2&gt;
        pair(pair&lt;_Other1, _Other2&gt;&amp;&amp; _Right,
            typename enable_if&lt;is_convertible&lt;_Other1, _Ty1&gt;::value
                &amp;&amp; is_convertible&lt;_Other2, _Ty2&gt;::value,
                void&gt;::type ** = 0)
        : first(_STD forward&lt;_Other1&gt;(_Right.first)),
            second(_STD forward&lt;_Other2&gt;(_Right.second))
        {    // construct from moved compatible pair
        }

</pre></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/A-moving-question/b905273e07b9452085c7a14101145737#b905273e07b9452085c7a14101145737</link>
		<pubDate>Wed, 09 Jan 2013 16:46:07 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/A-moving-question/b905273e07b9452085c7a14101145737#b905273e07b9452085c7a14101145737</guid>
		<dc:creator>NorvilleShaggy</dc:creator>
		<slash:comments>5</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/NorvilleShaggy/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - A moving question</title>
		<description><![CDATA[<p>Why can't container::value_type invoke a move like make_pair can ?</p><p>I'm using Visual Studio 2012</p><p>Code example</p><p><pre class="brush: cpp">#include &lt;iostream&gt;
#include &lt;unordered_map&gt;
#include &lt;utility&gt; // move, make_pair
#include &lt;algorithm&gt; // swap

struct move_me {
    typedef move_me class_type;
    int *ptr_value;
    int moved;
    int copied;

    move_me() : ptr_value(nullptr), moved(), copied() {}
    explicit move_me(const int val) : ptr_value(new int(val)), moved(), copied() {
    }
    ~move_me() {
        if (ptr_value) {
            delete ptr_value;
        }
    }

    // Copy
    move_me(const move_me &amp;other) :
        moved(other.moved), copied(other.copied &#43; 1) {
            if (other.ptr_value) {
                ptr_value = new int(*other.ptr_value);
            } else {
                ptr_value = nullptr;
            }
    }
    move_me &amp;operator=(const move_me &amp;other) {
        move_me(other).swap(*this);
        return *this;
    }

    // Move
    move_me(move_me &amp;&amp;other) {
        ptr_value = other.ptr_value;
        other.ptr_value = nullptr;
        moved = other.moved &#43; 1;
        copied = other.copied;
    }
    move_me &amp;operator=(move_me &amp;&amp;other) {
        move_me(std::move(other)).swap(*this);
        return *this;
    }

    void print() const {
        using namespace std;
        if (ptr_value)
            cout &lt;&lt; &quot;ptr_value: &quot; &lt;&lt; *ptr_value &lt;&lt; endl;
        else
            cout &lt;&lt; &quot;ptr_value: &lt;nullptr&gt;&quot; &lt;&lt; endl;
        cout &lt;&lt; &quot;moved: &quot; &lt;&lt; moved &lt;&lt; endl;
        cout &lt;&lt; &quot;copied: &quot; &lt;&lt; copied &lt;&lt; endl;
    }
    void swap(move_me&amp; other) {
        std::swap(ptr_value, other.ptr_value);
        std::swap(moved, other.moved);
        std::swap(copied, other.copied);
    }

    size_t hash() const {
        return std::hash&lt;int&gt;()(*ptr_value);
    }
    bool operator==(const class_type&amp; other) const { return *ptr_value == *other.ptr_value; }
    bool operator&lt; (const class_type&amp; other) const { return *ptr_value &lt; *other.ptr_value; }
    bool operator&lt;=(const class_type&amp; other) const { return *ptr_value &lt;= *other.ptr_value; }
};

struct hash_move_me {
    size_t operator()(const move_me&amp; key_val) const {
        return key_val.hash();
    }
};

int main()
{
    using namespace std;

    typedef unordered_map&lt;move_me, size_t, hash_move_me&gt; m_type;
    m_type m;

    auto find_and_prt = [&amp;](const int val) {
        m.find(move_me(val))-&gt;first.print();
        cout &lt;&lt; endl;
    };

    // Normal way
    // Expect only moves
    m.insert(m_type::value_type(move_me(111), 123));
    find_and_prt(111);

    // Lets make it very clear for the compiler that we want a move here
    m.insert(move(m_type::value_type(move(move_me(222)), 123)));
    find_and_prt(222);

    // We're in luck, special case, standard container
    m.insert(make_pair(move_me(333), 123));
    find_and_prt(333);

    cout &lt;&lt; &quot;done&quot; &lt;&lt; endl &lt;&lt; endl;
    return 0;
}</pre></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/A-moving-question/73db7dc02da14eaaa95ea14000da25b6#73db7dc02da14eaaa95ea14000da25b6</link>
		<pubDate>Tue, 08 Jan 2013 13:14:15 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/A-moving-question/73db7dc02da14eaaa95ea14000da25b6#73db7dc02da14eaaa95ea14000da25b6</guid>
		<dc:creator>NorvilleShaggy</dc:creator>
		<slash:comments>5</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/NorvilleShaggy/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>