title: How to remove a terminal character from a 'string' in C++ in O(1)?
body: <p>More formally, let <code>str</code> be the string in question, and let its length be <code>l</code>. I am aware that  the above can easily be accomplished using the <code>substr</code> function as follows: <br></p>
  
  <ul>
  <li>Removing the first character - <code>str.substr(1)</code> </li>
  <li>Removing the last character - <code>str.substr(0,l-1)</code></li>
  </ul>
  
  <p>But according to <a href="http://www.cplusplus.com/reference/string/string/substr/" rel="nofollow">this</a> page, the above method does so in <code>O(l)</code>.</p>
  
  <p>Is there a way to achieve the same in <code>O(1)</code>?</p>
  
  <p><strong>Edit</strong>: Before you mark this question as a duplicate, note that I am asking for an <strong><em>O(1)</em></strong> implementation for removing the terminal characters of a string. None of the answers to question of which this one is seemingly a duplicate of make any effort to answer this, apparently because <em>that</em> question doesn't ask for it.</p>