title: Does a getter have zero cost?
body: <p>I have a simple class:</p>
  
  <pre><code>class A {
      public:
      int get() const;
  
      private:
      void do_something();
      int value;
  }
  
  int A::get() const {
      return value;
  }
  </code></pre>
  
  <p>The getter function is simple and straightforward. Getters are to use them, so in do_something I should use <code>get()</code> in order to access <code>value</code>. My question is: will compiler optimize-out the getter, so it will be equivalent to accessing the data directly? Or I still will gain performance if I access it directly (what would imply worse design)?</p>
  
  <pre><code>A::do_something()
  {
      x = get();
      // or...
      x = value;
  }
  </code></pre>