is_aligned.hpp 602 B

12345678910111213141516171819202122232425262728
  1. /*
  2. Copyright 2014 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_ALIGN_IS_ALIGNED_HPP
  8. #define BOOST_ALIGN_IS_ALIGNED_HPP
  9. #include <boost/align/detail/is_aligned.hpp>
  10. #include <boost/align/detail/not_pointer.hpp>
  11. namespace boost {
  12. namespace alignment {
  13. template<class T>
  14. BOOST_CONSTEXPR inline typename detail::not_pointer<T, bool>::type
  15. is_aligned(T value, std::size_t alignment) BOOST_NOEXCEPT
  16. {
  17. return (value & (T(alignment) - 1)) == 0;
  18. }
  19. } /* alignment */
  20. } /* boost */
  21. #endif