How to ensure that values of a type may be manipulated only by its friends?
<p>I'd like to create a class template, <code>ptrs_and_refs_only&lt;T&gt;</code>, which only may be manipulated through pointers and references.  In other words, values of this type should be disallowed, except for things declared as <code>friend</code>s of the type.</p>

<p>Specifically, I'd like the compiler to issue an error if it encounters this type used as a function parameter:</p>

<pre><code>void foo(ptrs_and_refs_only&lt;int&gt; x);  // error!
void bar(ptrs_and_refs_only&lt;int&gt; &amp;x); // ok
void baz(ptrs_and_refs_only&lt;int&gt; *x); // ok
</code></pre>

<p>I know that I can make <code>ptrs_and_refs_only&lt;T&gt;</code>'s copy constructor <code>private</code>, but that doesn't seem to cause an error in this code:</p>

<pre><code>template&lt;typename T&gt;
  class ptrs_and_refs_only
{
  private:
    ptrs_and_refs_only() {}
    ptrs_and_refs_only(const ptrs_and_refs_only &amp;) {}
};

void foo(ptrs_and_refs_only&lt;int&gt; x) {}

int main()
{
  return 0;
}
</code></pre>

<p>Is this behavior possible?</p>
