diff options
Diffstat (limited to 'boost/align/detail')
25 files changed, 837 insertions, 0 deletions
diff --git a/boost/align/detail/address.hpp b/boost/align/detail/address.hpp new file mode 100644 index 0000000000..a4f3a6e84d --- /dev/null +++ b/boost/align/detail/address.hpp @@ -0,0 +1,27 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ADDRESS_HPP +#define BOOST_ALIGN_DETAIL_ADDRESS_HPP + +#include <boost/cstdint.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + namespace detail { +#if defined(BOOST_HAS_INTPTR_T) + typedef boost::uintptr_t address_t; +#else + typedef std::size_t address_t; +#endif + } + } +} + +#endif diff --git a/boost/align/detail/addressof.hpp b/boost/align/detail/addressof.hpp new file mode 100644 index 0000000000..d9d6f78ebc --- /dev/null +++ b/boost/align/detail/addressof.hpp @@ -0,0 +1,32 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ADDRESSOF_HPP +#define BOOST_ALIGN_DETAIL_ADDRESSOF_HPP + +#include <boost/config.hpp> + +#if !defined(BOOST_NO_CXX11_ADDRESSOF) +#include <memory> +#else +#include <boost/core/addressof.hpp> +#endif + +namespace boost { + namespace alignment { + namespace detail { +#if !defined(BOOST_NO_CXX11_ADDRESSOF) + using std::addressof; +#else + using boost::addressof; +#endif + } + } +} + +#endif diff --git a/boost/align/detail/align.hpp b/boost/align/detail/align.hpp new file mode 100644 index 0000000000..e3a90dffda --- /dev/null +++ b/boost/align/detail/align.hpp @@ -0,0 +1,38 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGN_HPP +#define BOOST_ALIGN_DETAIL_ALIGN_HPP + +#include <boost/assert.hpp> +#include <boost/align/detail/address.hpp> +#include <boost/align/detail/is_alignment.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + inline void* align(std::size_t alignment, std::size_t size, + void*& ptr, std::size_t& space) + { + BOOST_ASSERT(detail::is_alignment(alignment)); + std::size_t n = detail::address_t(ptr) & (alignment - 1); + if (n != 0) { + n = alignment - n; + } + void* p = 0; + if (n <= space && size <= space - n) { + p = static_cast<char*>(ptr) + n; + ptr = p; + space -= n; + } + return p; + } + } +} + +#endif diff --git a/boost/align/detail/align_cxx11.hpp b/boost/align/detail/align_cxx11.hpp new file mode 100644 index 0000000000..6672a7e0e9 --- /dev/null +++ b/boost/align/detail/align_cxx11.hpp @@ -0,0 +1,20 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP +#define BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP + +#include <memory> + +namespace boost { + namespace alignment { + using std::align; + } +} + +#endif diff --git a/boost/align/detail/aligned_alloc.hpp b/boost/align/detail/aligned_alloc.hpp new file mode 100644 index 0000000000..147b0de0f9 --- /dev/null +++ b/boost/align/detail/aligned_alloc.hpp @@ -0,0 +1,50 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_HPP +#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_HPP + +#include <boost/assert.hpp> +#include <boost/config.hpp> +#include <boost/align/align.hpp> +#include <boost/align/alignment_of.hpp> +#include <boost/align/detail/is_alignment.hpp> +#include <cstdlib> + +namespace boost { + namespace alignment { + inline void* aligned_alloc(std::size_t alignment, + std::size_t size) BOOST_NOEXCEPT + { + BOOST_ASSERT(detail::is_alignment(alignment)); + if (alignment < alignment_of<void*>::value) { + alignment = alignment_of<void*>::value; + } + std::size_t n = size + alignment - 1; + void* p1 = 0; + void* p2 = std::malloc(n + sizeof p1); + if (p2) { + p1 = static_cast<char*>(p2) + sizeof p1; + (void)align(alignment, size, p1, n); + *(static_cast<void**>(p1) - 1) = p2; + } + return p1; + } + + inline void aligned_free(void* ptr) + BOOST_NOEXCEPT + { + if (ptr) { + void* p = *(static_cast<void**>(ptr) - 1); + std::free(p); + } + } + } +} + +#endif diff --git a/boost/align/detail/aligned_alloc_android.hpp b/boost/align/detail/aligned_alloc_android.hpp new file mode 100644 index 0000000000..2b813becae --- /dev/null +++ b/boost/align/detail/aligned_alloc_android.hpp @@ -0,0 +1,35 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_ANDROID_HPP +#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_ANDROID_HPP + +#include <boost/assert.hpp> +#include <boost/config.hpp> +#include <boost/align/detail/is_alignment.hpp> +#include <cstddef> +#include <malloc.h> + +namespace boost { + namespace alignment { + inline void* aligned_alloc(std::size_t alignment, + std::size_t size) BOOST_NOEXCEPT + { + BOOST_ASSERT(detail::is_alignment(alignment)); + return ::memalign(alignment, size); + } + + inline void aligned_free(void* ptr) + BOOST_NOEXCEPT + { + ::free(ptr); + } + } +} + +#endif diff --git a/boost/align/detail/aligned_alloc_macos.hpp b/boost/align/detail/aligned_alloc_macos.hpp new file mode 100644 index 0000000000..346eabfc58 --- /dev/null +++ b/boost/align/detail/aligned_alloc_macos.hpp @@ -0,0 +1,45 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP +#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MACOS_HPP + +#include <boost/assert.hpp> +#include <boost/config.hpp> +#include <boost/align/detail/is_alignment.hpp> +#include <cstddef> +#include <stdlib.h> + +namespace boost { + namespace alignment { + inline void* aligned_alloc(std::size_t alignment, + std::size_t size) BOOST_NOEXCEPT + { + BOOST_ASSERT(detail::is_alignment(alignment)); + if (!size) { + return 0; + } + if (alignment < sizeof(void*)) { + alignment = sizeof(void*); + } + void* p; + if (::posix_memalign(&p, alignment, size) != 0) { + p = 0; + } + return p; + } + + inline void aligned_free(void* ptr) + BOOST_NOEXCEPT + { + ::free(ptr); + } + } +} + +#endif diff --git a/boost/align/detail/aligned_alloc_msvc.hpp b/boost/align/detail/aligned_alloc_msvc.hpp new file mode 100644 index 0000000000..570a898c59 --- /dev/null +++ b/boost/align/detail/aligned_alloc_msvc.hpp @@ -0,0 +1,35 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MSVC_HPP +#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_MSVC_HPP + +#include <boost/assert.hpp> +#include <boost/config.hpp> +#include <boost/align/detail/is_alignment.hpp> +#include <cstddef> +#include <malloc.h> + +namespace boost { + namespace alignment { + inline void* aligned_alloc(std::size_t alignment, + std::size_t size) BOOST_NOEXCEPT + { + BOOST_ASSERT(detail::is_alignment(alignment)); + return ::_aligned_malloc(size, alignment); + } + + inline void aligned_free(void* ptr) + BOOST_NOEXCEPT + { + ::_aligned_free(ptr); + } + } +} + +#endif diff --git a/boost/align/detail/aligned_alloc_posix.hpp b/boost/align/detail/aligned_alloc_posix.hpp new file mode 100644 index 0000000000..ceab4cbe9c --- /dev/null +++ b/boost/align/detail/aligned_alloc_posix.hpp @@ -0,0 +1,42 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_POSIX_HPP +#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_POSIX_HPP + +#include <boost/assert.hpp> +#include <boost/config.hpp> +#include <boost/align/detail/is_alignment.hpp> +#include <cstddef> +#include <stdlib.h> + +namespace boost { + namespace alignment { + inline void* aligned_alloc(std::size_t alignment, + std::size_t size) BOOST_NOEXCEPT + { + BOOST_ASSERT(detail::is_alignment(alignment)); + if (alignment < sizeof(void*)) { + alignment = sizeof(void*); + } + void* p; + if (::posix_memalign(&p, alignment, size) != 0) { + p = 0; + } + return p; + } + + inline void aligned_free(void* ptr) + BOOST_NOEXCEPT + { + ::free(ptr); + } + } +} + +#endif diff --git a/boost/align/detail/aligned_alloc_sunos.hpp b/boost/align/detail/aligned_alloc_sunos.hpp new file mode 100644 index 0000000000..a2373bd26b --- /dev/null +++ b/boost/align/detail/aligned_alloc_sunos.hpp @@ -0,0 +1,35 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_SUNOS_HPP +#define BOOST_ALIGN_DETAIL_ALIGNED_ALLOC_SUNOS_HPP + +#include <boost/assert.hpp> +#include <boost/config.hpp> +#include <boost/align/detail/is_alignment.hpp> +#include <cstddef> +#include <stdlib.h> + +namespace boost { + namespace alignment { + inline void* aligned_alloc(std::size_t alignment, + std::size_t size) BOOST_NOEXCEPT + { + BOOST_ASSERT(detail::is_alignment(alignment)); + return ::memalign(alignment, size); + } + + inline void aligned_free(void* ptr) + BOOST_NOEXCEPT + { + ::free(ptr); + } + } +} + +#endif diff --git a/boost/align/detail/alignment_of.hpp b/boost/align/detail/alignment_of.hpp new file mode 100644 index 0000000000..1fa3070ce0 --- /dev/null +++ b/boost/align/detail/alignment_of.hpp @@ -0,0 +1,27 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP +#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_HPP + +#include <boost/align/detail/min_size.hpp> +#include <boost/align/detail/offset_object.hpp> + +namespace boost { + namespace alignment { + namespace detail { + template<class T> + struct alignment_of + : min_size<sizeof(T), + sizeof(offset_object<T>) - sizeof(T)>::type { + }; + } + } +} + +#endif diff --git a/boost/align/detail/alignment_of_clang.hpp b/boost/align/detail/alignment_of_clang.hpp new file mode 100644 index 0000000000..18d7c718db --- /dev/null +++ b/boost/align/detail/alignment_of_clang.hpp @@ -0,0 +1,26 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CLANG_HPP +#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CLANG_HPP + +#include <boost/align/detail/integral_constant.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + namespace detail { + template<class T> + struct alignment_of + : integral_constant<std::size_t, __alignof(T)> { + }; + } + } +} + +#endif diff --git a/boost/align/detail/alignment_of_codegear.hpp b/boost/align/detail/alignment_of_codegear.hpp new file mode 100644 index 0000000000..9074967f49 --- /dev/null +++ b/boost/align/detail/alignment_of_codegear.hpp @@ -0,0 +1,26 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CODEGEAR_HPP +#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CODEGEAR_HPP + +#include <boost/align/detail/integral_constant.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + namespace detail { + template<class T> + struct alignment_of + : integral_constant<std::size_t, alignof(T)> { + }; + } + } +} + +#endif diff --git a/boost/align/detail/alignment_of_cxx11.hpp b/boost/align/detail/alignment_of_cxx11.hpp new file mode 100644 index 0000000000..d5d00a08b4 --- /dev/null +++ b/boost/align/detail/alignment_of_cxx11.hpp @@ -0,0 +1,22 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CXX11_HPP +#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_CXX11_HPP + +#include <type_traits> + +namespace boost { + namespace alignment { + namespace detail { + using std::alignment_of; + } + } +} + +#endif diff --git a/boost/align/detail/alignment_of_gcc.hpp b/boost/align/detail/alignment_of_gcc.hpp new file mode 100644 index 0000000000..3044b2a3ec --- /dev/null +++ b/boost/align/detail/alignment_of_gcc.hpp @@ -0,0 +1,26 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_GCC_HPP +#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_GCC_HPP + +#include <boost/align/detail/integral_constant.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + namespace detail { + template<class T> + struct alignment_of + : integral_constant<std::size_t, __alignof__(T)> { + }; + } + } +} + +#endif diff --git a/boost/align/detail/alignment_of_msvc.hpp b/boost/align/detail/alignment_of_msvc.hpp new file mode 100644 index 0000000000..a86f785ddc --- /dev/null +++ b/boost/align/detail/alignment_of_msvc.hpp @@ -0,0 +1,27 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_ALIGNMENT_OF_MSVC_HPP +#define BOOST_ALIGN_DETAIL_ALIGNMENT_OF_MSVC_HPP + +#include <boost/align/detail/min_size.hpp> +#include <boost/align/detail/offset_object.hpp> + +namespace boost { + namespace alignment { + namespace detail { + template<class T> + struct alignment_of + : min_size<sizeof(T), + offsetof(offset_object<T>, object)>::type { + }; + } + } +} + +#endif diff --git a/boost/align/detail/integral_constant.hpp b/boost/align/detail/integral_constant.hpp new file mode 100644 index 0000000000..332aade943 --- /dev/null +++ b/boost/align/detail/integral_constant.hpp @@ -0,0 +1,46 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_INTEGRAL_CONSTANT_HPP +#define BOOST_ALIGN_DETAIL_INTEGRAL_CONSTANT_HPP + +#include <boost/config.hpp> + +#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) +#include <type_traits> +#endif + +namespace boost { + namespace alignment { + namespace detail { +#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) + using std::integral_constant; +#else + template<class T, T Value> + struct integral_constant { + typedef T value_type; + typedef integral_constant<T, Value> type; + +#if !defined(BOOST_NO_CXX11_CONSTEXPR) + constexpr operator value_type() const { + return Value; + } + + static constexpr T value = Value; +#else + enum { + value = Value + }; +#endif + }; +#endif + } + } +} + +#endif diff --git a/boost/align/detail/is_aligned.hpp b/boost/align/detail/is_aligned.hpp new file mode 100644 index 0000000000..41fb80581f --- /dev/null +++ b/boost/align/detail/is_aligned.hpp @@ -0,0 +1,29 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_IS_ALIGNED_HPP +#define BOOST_ALIGN_DETAIL_IS_ALIGNED_HPP + +#include <boost/assert.hpp> +#include <boost/config.hpp> +#include <boost/align/detail/address.hpp> +#include <boost/align/detail/is_alignment.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + inline bool is_aligned(std::size_t alignment, + const void* ptr) BOOST_NOEXCEPT + { + BOOST_ASSERT(detail::is_alignment(alignment)); + return (detail::address_t(ptr) & (alignment - 1)) == 0; + } + } +} + +#endif diff --git a/boost/align/detail/is_alignment.hpp b/boost/align/detail/is_alignment.hpp new file mode 100644 index 0000000000..532198363f --- /dev/null +++ b/boost/align/detail/is_alignment.hpp @@ -0,0 +1,27 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_IS_ALIGNMENT_HPP +#define BOOST_ALIGN_DETAIL_IS_ALIGNMENT_HPP + +#include <boost/config.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + namespace detail { + BOOST_CONSTEXPR inline bool is_alignment(std::size_t + value) BOOST_NOEXCEPT + { + return (value > 0) && ((value & (value - 1)) == 0); + } + } + } +} + +#endif diff --git a/boost/align/detail/is_alignment_constant.hpp b/boost/align/detail/is_alignment_constant.hpp new file mode 100644 index 0000000000..8f422608ae --- /dev/null +++ b/boost/align/detail/is_alignment_constant.hpp @@ -0,0 +1,27 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_IS_ALIGNMENT_CONSTANT_HPP +#define BOOST_ALIGN_DETAIL_IS_ALIGNMENT_CONSTANT_HPP + +#include <boost/align/detail/integral_constant.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + namespace detail { + template<std::size_t N> + struct is_alignment_constant + : integral_constant<bool, + (N > 0) && ((N & (N - 1)) == 0)> { + }; + } + } +} + +#endif diff --git a/boost/align/detail/max_align.hpp b/boost/align/detail/max_align.hpp new file mode 100644 index 0000000000..775121d83a --- /dev/null +++ b/boost/align/detail/max_align.hpp @@ -0,0 +1,27 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_MAX_ALIGN_HPP +#define BOOST_ALIGN_DETAIL_MAX_ALIGN_HPP + +#include <boost/align/detail/integral_constant.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + namespace detail { + template<std::size_t A, std::size_t B> + struct max_align + : integral_constant<std::size_t, + (A > B) ? A : B> { + }; + } + } +} + +#endif diff --git a/boost/align/detail/max_count_of.hpp b/boost/align/detail/max_count_of.hpp new file mode 100644 index 0000000000..3ba4eae70e --- /dev/null +++ b/boost/align/detail/max_count_of.hpp @@ -0,0 +1,27 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_MAX_COUNT_OF_HPP +#define BOOST_ALIGN_DETAIL_MAX_COUNT_OF_HPP + +#include <boost/align/detail/integral_constant.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + namespace detail { + template<class T> + struct max_count_of + : integral_constant<std::size_t, + ~static_cast<std::size_t>(0) / sizeof(T)> { + }; + } + } +} + +#endif diff --git a/boost/align/detail/min_size.hpp b/boost/align/detail/min_size.hpp new file mode 100644 index 0000000000..80d3a7a6ed --- /dev/null +++ b/boost/align/detail/min_size.hpp @@ -0,0 +1,27 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_MIN_SIZE_HPP +#define BOOST_ALIGN_DETAIL_MIN_SIZE_HPP + +#include <boost/align/detail/integral_constant.hpp> +#include <cstddef> + +namespace boost { + namespace alignment { + namespace detail { + template<std::size_t A, std::size_t B> + struct min_size + : integral_constant<std::size_t, + (A < B) ? A : B> { + }; + } + } +} + +#endif diff --git a/boost/align/detail/offset_object.hpp b/boost/align/detail/offset_object.hpp new file mode 100644 index 0000000000..8168595230 --- /dev/null +++ b/boost/align/detail/offset_object.hpp @@ -0,0 +1,24 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_OFFSET_OBJECT_HPP +#define BOOST_ALIGN_DETAIL_OFFSET_OBJECT_HPP + +namespace boost { + namespace alignment { + namespace detail { + template<class T> + struct offset_object { + char offset; + T object; + }; + } + } +} + +#endif diff --git a/boost/align/detail/remove_traits.hpp b/boost/align/detail/remove_traits.hpp new file mode 100644 index 0000000000..d44860ed6b --- /dev/null +++ b/boost/align/detail/remove_traits.hpp @@ -0,0 +1,90 @@ +/* + (c) 2014 Glen Joseph Fernandes + glenjofe at gmail dot com + + Distributed under the Boost Software + License, Version 1.0. + http://boost.org/LICENSE_1_0.txt +*/ +#ifndef BOOST_ALIGN_DETAIL_REMOVE_TRAITS_HPP +#define BOOST_ALIGN_DETAIL_REMOVE_TRAITS_HPP + +#include <boost/config.hpp> + +#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) +#include <type_traits> +#else +#include <cstddef> +#endif + +namespace boost { + namespace alignment { + namespace detail { +#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) + using std::remove_reference; + using std::remove_all_extents; + using std::remove_cv; +#else + template<class T> + struct remove_reference { + typedef T type; + }; + + template<class T> + struct remove_reference<T&> { + typedef T type; + }; + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template<class T> + struct remove_reference<T&&> { + typedef T type; + }; +#endif + + template<class T> + struct remove_all_extents { + typedef T type; + }; + + template<class T> + struct remove_all_extents<T[]> { + typedef typename remove_all_extents<T>::type type; + }; + + template<class T, std::size_t N> + struct remove_all_extents<T[N]> { + typedef typename remove_all_extents<T>::type type; + }; + + template<class T> + struct remove_const { + typedef T type; + }; + + template<class T> + struct remove_const<const T> { + typedef T type; + }; + + template<class T> + struct remove_volatile { + typedef T type; + }; + + template<class T> + struct remove_volatile<volatile T> { + typedef T type; + }; + + template<class T> + struct remove_cv { + typedef typename remove_volatile<typename + remove_const<T>::type>::type type; + }; +#endif + } + } +} + +#endif |