title: Check input buffer alignment in C++/C++11: what is the best way?
body: <p>I know C++11 provides <a href="http://en.cppreference.com/w/cpp/language/alignof" rel="nofollow noreferrer">alignof</a>, <a href="http://en.cppreference.com/w/cpp/language/alignas" rel="nofollow noreferrer">alignas</a> and <a href="http://en.cppreference.com/w/cpp/memory/align" rel="nofollow noreferrer">align</a>, but in this case I want to check an input buffer that is already allocated.</p>
  
  <p>I know also that C provides <code>uintptr_t</code> to precisely fit a pointer type in a conversion to integer (and then checking alignment would be easy), but this data type is <a href="https://stackoverflow.com/a/1846648/2436175">not guaranteed to be there in C++/C++11</a>.</p>
  
  <p>The question is answered <a href="https://stackoverflow.com/q/6240330/2436175">here</a> for C. It seems that a conversion to any integer would be ok in this case, but in C++ I get a "loses precision" warning.</p>
  
  <p>So, now I look at <a href="https://stackoverflow.com/questions/153065/converting-a-pointer-into-an-integer">Converting a pointer into an integer</a>, but there I find an abundant use of <code>uintptr_t</code>, which is not guaranteed to be there.</p>
  
  <p>So, what is the best way to check if an input pointer is aligned in C++/C++11?</p>
  
  <p>(Note: After all this research and reasoning I came up with a solution, but I am looking forward to other proposals!)</p>