title: Design of constexpr classes : merging constexpr and non-constexpr versions?
body: <p>Consider a class that just wraps a value at runtime :</p>
  
  <pre><code>template &lt;typename Type&gt;
  class NonConstValue 
  {
      public:
          NonConstValue(const Type&amp; val) : _value(val) {;}
          Type get() const {return _value;}
          void set(const Type&amp; val) const {_value = val;}
      protected:
          Type _value;
  };
  </code></pre>
  
  <p>and the constexpr version of that:</p>
  
  <pre><code>template &lt;typename Type&gt;
  class ConstValue 
  {
      public:
          constexpr ConstValue(const Type&amp; val) : _value(val) {;}
          constexpr Type get() const {return _value;}
      protected:
          const Type _value;
  };
  </code></pre>
  
  <p>Question 1 : Can you confirm that the constexpr version is designed in the right way ?</p>
  
  <p>Question 2 : How do you mix both classes into a single one called <code>Value</code> that can be <code>constexpr</code> constructed or runtime constructed and whose value can be <code>get()</code> at runtime or compile-time ?</p>
  
  <p>EDIT : 
  Question 3 : If <code>get()</code> is defined in a <code>.cpp</code> file, and if I want <code>get()</code> to be inlined if it's not a <code>constexpr</code> what is the right declaration of the function ? Is it </p>
  
  <pre><code>constexpr inline Type get();
  </code></pre>
  
  <p>or </p>
  
  <pre><code>inline constexpr Type get()
  </code></pre>
  
  <p>or something else ?</p>