align_down.hpp 593 B

123456789101112131415161718192021222324252627
  1. /*
  2. Copyright 2015 Glen Joseph Fernandes
  3. ([email protected])
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_ALIGN_ALIGN_DOWN_HPP
  8. #define BOOST_ALIGN_ALIGN_DOWN_HPP
  9. #include <boost/align/detail/align_down.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, T>::type
  15. align_down(T value, std::size_t alignment) BOOST_NOEXCEPT
  16. {
  17. return T(value & ~T(alignment - 1));
  18. }
  19. } /* alignment */
  20. } /* boost */
  21. #endif