conditionally trivial templated class
<p>have trivial base class for block of data similar to</p>

<pre><code>template&lt;int N&gt;
class Block {
  public:
    char body[N];
    Block&amp; operator=( const char * );
    template&lt;int R&gt;
      Block&amp; operator=( const Block&lt;R&gt;&amp; );
};
</code></pre>

<p>commonly typedef'd something like</p>

<pre><code>typedef Block&lt;20&gt; name_t;
typedef Block&lt;40&gt; full_t;
</code></pre>

<p>and used in anonymous unions</p>

<pre><code>union Name {
  struct {
    name_t first;
    name_t last;
  };
  full_t full;
};
</code></pre>

<p>ideally the same typedef would be used as parameter type</p>

<pre><code>void hello( full_t n );
</code></pre>

<p>however making the class trivial loses some functionality</p>

<pre><code>// Block&lt;10&gt; f = "fred";  // would require constructor
Block&lt;10&gt; f; f = "Fred";

hello( f );               // would require constructor
</code></pre>

<p>derived class with constructor can bring back some lost functionality</p>

<pre><code>template&lt;int N&gt;
class Param : public Block&lt;N&gt; {
  public:
    template&lt;int R&gt;
      Param( const Block&lt;R&gt;&amp; );
};
</code></pre>

<p>and using the derived class is an option</p>

<pre><code>void hello( Param&lt;40&gt; n );
</code></pre>

<p>am looking for more elegant solution that can allow the same type definition both in anonymous unions and as parameter type to a function - something like</p>

<pre><code>void hello( notrivial&lt; full_t &gt; );
</code></pre>

<p>but am not seeing how to pull that off...   possibly using concept checking or traits approach but notation escapes me.  to make the solution more elusive using newer c11 features is not an option in this environment.</p>

<p><strong>my question is: must the non-trivial always be a different (possibly derived) class or can anyone see how to define a class that is 'optionally' trivial?</strong></p>

<p>any help most welcome, thanks</p>
