title: Encapsulate a simple type using C++ templates
body: <p>I'm looking to add functionality to all the simple types in C++. </p>
  
  <p>I want to write a single templated class that takes as a template parameter the type to be encapsulated and then has all the operators defined so that the encapsulated class works exactly as the simple type it encapsulates.</p>
  
  <p>Something like this:</p>
  
  <pre><code>template &lt;typename _SimpleType_&gt;
  class Attribute
  {
  public:
      Attribute(_SimpleType_ value){ m_value = value; }
      ~Attribute(){}
  
      // Cast
      operator _SimpleType_() { return(m_value); }
  
      // Comparisons
      bool operator==(const a&amp; other) const { return a == m_value; }
      etc...
  
  private:
     _SimpleType_ m_value;
  }
  
  // Use like:
  Attribute&lt;int&gt; i = 20;
  
  while(i)
  {
     if((i &amp; 0xF) == 0)
     {
        i &gt;&gt;= 2;
     }
  
     i--;
  }  etc...
  </code></pre>
  
  <p>The question is I'm sure there are a load of nuances that have to be dealt with and specialised template operators written; so is there anywhere that this has already been done so that I can just use that instead?  </p>
  
  <p>Boost is too large and complicated to put in my project but I can look at it for pointers if there is a class like this in there - whats its name if there is?</p>