title: Is there a way to define traits and cast operators for redefined, via `typedef`, basic types?
body: <p>I've written a pair of converter functions for conversions between the floating point representation of angles in radians and the binary angles (aka <a href="https://en.wikipedia.org/wiki/Binary_scaling#Binary_angles" rel="nofollow noreferrer">BAMS</a>):</p>
  
  <pre><code>// Binary angles that maps into 360 degree circle
  typedef uint8_t  binang8_t;
  typedef uint16_t binang16_t;
  typedef uint32_t binang32_t;
  typedef uint64_t binang64_t;
  
  // Convert from radians to BAMS
  template&lt;typename A, typename T&gt; A to_binang(T val);
  
  // Convert from radians or BAMS
  template&lt;typename T, typename A&gt; T to_rads(A val);
  </code></pre>
  
  <p>The main issue is my <code>is_binangle</code>trait I created for use inside the converters does not protect against use of unsigned integers in place of new types. <strong><em>I know, I can define those new types as structures and it will solve this problem</em></strong> , but I have reason not to declare them as <code>class</code> or <code>struct</code>(to avoid redefining arithmetic operators and to stay compatible with old C payload headers). Is there a trick to get it working with types defined using <code>typedef</code>?
  Here is my attempt at implementing that trait :</p>
  
  <pre><code>template&lt;typename T&gt; struct is_binangle {
      static const bool value = false;
  };
  
  template&lt;&gt; struct is_binangle&lt;binang8_t&gt; {
      static const bool value = true;
  };
  
  template&lt;&gt; struct is_binangle&lt;binang16_t&gt; {
      static const bool value = true;
  };
  
  ...
  </code></pre>
  
  <p>Ideally I'd prefer to define custom casts for those types, so that one can convert by just:</p>
  
  <pre><code>double rangle = M_PI/6;
  binang16_t bang =  binang16_t(rangle);
  bang += bang;
  double another_rangle = double(another_bang);
  </code></pre>
  
  <p>I have strong suspicion that it is impossible unless those binary angles are <code>classes</code>/<code>structures</code> . Is it right?</p>