title: Recycling member functionality without inheritance
body: <p>There is an interesting template presented on Wikipedia for <a href="http://en.wikipedia.org/wiki/Property_(programming)#C.2B.2B" rel="nofollow">Properties</a>. </p>
  
  <p>This template provides something interesting, in that it allows providing logic around member accesses. Building on this, we could easily build something like this: </p>
  
  <pre><code>struct Ranged { 
    ranged_property&lt;float,0,1&gt; unit_property; 
  }; 
  </code></pre>
  
  <p>Where the range of <code>unit_property</code> is enforced to be within [0,1]. </p>
  
  <p>How can we provide a similar functionality the depends on the hosting class' members? For example: </p>
  
  <pre><code>struct AdjustableRanged { 
    float max; 
    ranged_property&lt;float,0,max&gt; influenceable_property; 
  };
  </code></pre>
  
  <p>Where the range of <code>influenceable_property</code> is affected by the value of <code>max</code>. Keep in mind, the goal is for this kind of template to be recycled across many vastly different classes. Related concepts are mixins and decorators. </p>
  
  <p>It can be done with macros... but I feel like there <em>must</em> be a better more idiomatic C++ solution.</p>
  
  <hr>
  
  <p>Edited to add: I think this could be done by saving a reference to the member inside the ranged_property template... but that seems to be a complete waste of space for what would be effectively a constant value;  <strong>ETA</strong>; A const reference may serve the purpose actually, however, I need to do the investigation. </p>