Explicitly Disallowing Compiler Generated Functions
<p>Lately I have been working through Meyers' Effective C++ Third Edition. For a project I am currently working on I have had to create a class that I explicitly want to disallow the use of compiler generated functions. I implemented code using Item 6 in said book as a reference, the only major difference in that my class is Templated. The code for it is as follows </p>

<pre><code>template &lt;class T&gt;
class Uncopyable
{
protected:
    Uncopyable&lt;T&gt;(){}
    virtual ~Uncopyable&lt;T&gt;(){}
private:
    Uncopyable&lt;T&gt;(const Uncopyable&lt;T&gt;&amp;);
    Uncopyable&lt;T&gt;&amp; operator=(const Uncopyable&lt;T&gt;&amp;);
};
</code></pre>

<p>My test function.</p>

<pre><code>class Test : private Uncopyable&lt;Test&gt;
{
public:
    Test(){}
    ~Test(){}
    inline void test()
    {
        std::cout &lt;&lt; "blah" &lt;&lt; std::endl;
    }
private:
protected:
};
</code></pre>

<p>When used like this the code works completely as expected</p>

<pre><code>int main(int argc, char* argv[])
{
    Test t1, t2;

    // Works as expected, doesnt allow copying of object
    t2 = t1;
    // and this works fine, no copying
    Test t3 = t2;

    // finally, works correctly no copying is allowed
    Test t4(t1);

    return 0;
}
</code></pre>

<p>When used like this however, the code compiles fine and copying can take place, when it should not be able to?</p>

<pre><code>int main(int argc, char* argv[])
{
    Test* t1 = new Test(), *t2;
    t1-&gt;test();
    // Works when it shouldnt work?
    t2 = t1;
    t2-&gt;test();

    // same with this
    Test* t3 = t2;
    t3-&gt;test();

    // and this
    Test* t4(t1);
    t4-&gt;test();

    delete t1;

    return 0;
}
</code></pre>

<p>I have tried it without the template class and the result is the same, so I don't think that is the issue.</p>

<p>So SO, why is this allowed to happen? Is there an error in my code, or am I just understanding the concept wrong? Thanks.</p>
