Remove CDS_RVALUE_SUPPORT, CDS_MOVE_SEMANTICS_SUPPORT macros and emulating code
[libcds.git] / cds / details / is_aligned.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_DETAILS_IS_ALIGNED_H
4 #define __CDS_DETAILS_IS_ALIGNED_H
5
6 #include <cds/details/defs.h>
7
8 namespace cds { namespace details {
9
10     /// Checks if the pointer \p p has \p ALIGN byte alignment
11     /**
12         \p ALIGN must be power of 2.
13
14         The function is mostly intended for run-time assertion
15     */
16     template <int ALIGN, typename T>
17     static inline bool is_aligned(T const * p)
18     {
19         return (((uptr_atomic_t)p) & uptr_atomic_t(ALIGN - 1)) == 0;
20     }
21
22     /// Checks if the pointer \p p has \p nAlign byte alignment
23     /**
24         \p nAlign must be power of 2.
25
26         The function is mostly intended for run-time assertion
27     */
28     template <typename T>
29     static inline bool is_aligned(T const * p, size_t nAlign)
30     {
31         return (((uptr_atomic_t)p) & uptr_atomic_t(nAlign - 1)) == 0;
32     }
33
34 }} // namespace cds::details
35
36 #endif // #ifndef __CDS_DETAILS_IS_ALIGNED_H