title: How to set a const int to maximum in C++?
body: <p>I have a static const member and would like to set it to the maximum integer. I'm trying the following:</p>
  
  <pre><code>const static int MY_VALUE = std::numeric_limits&lt;int&gt;::max();
  </code></pre>
  
  <p>But get the following error:</p>
  
  <blockquote>
    <p>error: in-class initializer for static data member is not a constant
    expression</p>
  </blockquote>
  
  <p>Is there any solution to this? How can a function <em>not</em> return a constant expression?</p>
  
  <p><strong>EDIT:</strong> Adding -std=c++11 fixed the issue. My roommate tells me that the compiler (pre C++11) isn't smart enough to decide that std::numeric_limits::max() doesn't mutate anything else, and so is not considered constant. Is that possibly the reason for this error?</p>