1 /* 2 Copyright 2014 Glen Joseph Fernandes 3 (glenjofe@gmail.com) 4 5 Distributed under the Boost Software License, Version 1.0. 6 (http://www.boost.org/LICENSE_1_0.txt) 7 */ 8 #ifndef BOOST_ALIGN_DETAIL_IS_ALIGNED_HPP 9 #define BOOST_ALIGN_DETAIL_IS_ALIGNED_HPP 10 11 #include <boost/align/detail/is_alignment.hpp> 12 #include <boost/assert.hpp> 13 14 namespace boost { 15 namespace alignment { 16 17 inline bool is_aligned(const volatile void * ptr,std::size_t alignment)18is_aligned(const volatile void* ptr, std::size_t alignment) BOOST_NOEXCEPT 19 { 20 BOOST_ASSERT(detail::is_alignment(alignment)); 21 return (reinterpret_cast<std::size_t>(ptr) & (alignment - 1)) == 0; 22 } 23 24 inline bool is_aligned(std::size_t alignment,const volatile void * ptr)25is_aligned(std::size_t alignment, const volatile void* ptr) BOOST_NOEXCEPT 26 { 27 BOOST_ASSERT(detail::is_alignment(alignment)); 28 return (reinterpret_cast<std::size_t>(ptr) & (alignment - 1)) == 0; 29 } 30 31 } /* alignment */ 32 } /* boost */ 33 34 #endif 35