title: What's the safest way to define short function name aliases in C++?
body: <p>Suppose I have a class <code>Utility</code> in a file <code>utility.h</code>:</p>
  
  <pre><code>class Utility {
  public:
      static double longDescriptiveName(double x) { return x + 42; }
  };
  </code></pre>
  
  <p>And then I find that I use the function <code>longDescriptiveName(...)</code> a LOT. So like an irresponsible C++ programmer that I am when I've had too much coffee, I create a new file <code>utilitymacros.h</code> and add the following there:</p>
  
  <pre><code>#define ldn Utility::longDescriptiveName
  </code></pre>
  
  <p>Now I include <code>"utilitymacros.h"</code> in any <code>*.cpp</code> where I use <code>ldn(...)</code> and my heart is filled with joy over how much more convinient it is to type 3 letters vs 28.</p>
  
  <p><strong>Question:</strong> Is there a safer (more proper) way of doing this than with <code>#define</code>?</p>
  
  <p>I've noticed that I have to include "utilitymacros.h" after including boost headers, which I obviously don't like because it's a sign of clashes (though the Boost errors I get are not very clear as to what the clash is).</p>
  
  <p><strong>Clarification 1: On Code Readability</strong></p>
  
  <p>In case you might say that this negatively affects code readability, I assure you it does not, because it's a small set of functions that are used A LOT. An example that is widely know is <code>stoi</code> for <code>stringToInteger</code>. Another is <code>pdf</code> for <code>probabilityDensityFunction</code>, etc. So if I want to do the following, <code>stoi</code> is more readable in my opinion:</p>
  
  <pre><code>int x = stoi(a) + stoi(b) + stoi(c) + stoi(d);
  </code></pre>
  
  <p>Than:</p>
  
  <pre><code>int x = Utility::stringToInteger(a) + Utility::stringToInteger(b)
          + Utility::stringToInteger(c) + Utility::stringToInteger(d);
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>int x = Utility::stringToInteger(a);
  x += Utility::stringToInteger(b);
  x += Utility::stringToInteger(c);
  x += Utility::stringToInteger(d);
  </code></pre>
  
  <p><strong>Clarification 2: Editor Macro</strong></p>
  
  <p>I use Emacs as my IDE of choice and a Kinesis keyboard so you KNOW I use a ton of keyboard macros, custom keyboard shortcuts, as well as actually modifying what I see in the editor vs what's actually stored in the h/cpp file. But still, I feel like the simplicity and visual readability (as argued above) of using a function abbreviation in a few select cases really is the result I'm looking for (this is certainly subject to a degree).</p>