title: How to duplicate a function which returns const reference by a function which returns non-const reference?
body: <p>Here is my code snippet:</p>
  
  <pre><code>inline uint8_t &amp;AT(uint16_t addr) { // non-const version
      return (addr &lt; 0x2000 ? Ram[addr &amp; 0x7ff]:        \
      addr &lt; 0x4000 ? PPURegister[(addr - 0x2000) &amp; 0x7]: \
      addr &lt; 0x4020 ? APUIORegister[(addr - 0x4000)]:     \
      addr &lt; 0x6000 ? ExpansionRom[addr - 0x4020]:        \
      addr &lt; 0x8000 ? SRam[addr - 0x6000]:                \
      addr &lt; 0xc000 ? LowerPRGRom[addr - 0x8000]:         \
      UpperPRGRom[addr - 0xc000]);
  }
  
  inline const uint8_t &amp;AT(uint16_t addr) const { // const version
      return AT(addr); // Function `AT` will recurses infinitely! But I don't want to copy the body of non-const function here.
  }
  </code></pre>
  
  <p>There are functions uses it:</p>
  
  <pre><code>uint8_t &amp;operator[](uint16_t addr) { return AT(addr); }
  const uint8_t &amp;operator[](uint16_t addr) const { return AT(addr); }
  </code></pre>
  
  <p>so, how to implement the function which returns const simply and clearly?</p>