Rename detail offset_object to alignof_helper

This commit is contained in:
Glen Fernandes 2015-08-07 07:49:47 -04:00
parent 0771bce1f8
commit d979a2536f
4 changed files with 30 additions and 29 deletions

View File

@ -1,6 +1,6 @@
/*
(c) 2014 Glen Joseph Fernandes
glenjofe at gmail dot com
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
@ -9,8 +9,8 @@ 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/alignof_helper.hpp>
#include <boost/align/detail/min_size.hpp>
#include <boost/align/detail/offset_object.hpp>
namespace boost {
namespace alignment {
@ -19,11 +19,11 @@ namespace detail {
template<class T>
struct alignment_of
: min_size<sizeof(T),
sizeof(offset_object<T>) - sizeof(T)>::type {
sizeof(alignof_helper<T>) - sizeof(T)>::type {
};
} /* :detail */
} /* :alignment */
} /* :boost */
} /* .detail */
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,6 +1,6 @@
/*
(c) 2014 Glen Joseph Fernandes
glenjofe at gmail dot com
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
@ -9,8 +9,8 @@ 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/alignof_helper.hpp>
#include <boost/align/detail/min_size.hpp>
#include <boost/align/detail/offset_object.hpp>
namespace boost {
namespace alignment {
@ -18,11 +18,12 @@ namespace detail {
template<class T>
struct alignment_of
: min_size<sizeof(T), offsetof(offset_object<T>, object)>::type {
: min_size<sizeof(T),
offsetof(alignof_helper<T>, object)>::type {
};
} /* :detail */
} /* :alignment */
} /* :boost */
} /* .detail */
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,26 +1,26 @@
/*
(c) 2014 Glen Joseph Fernandes
glenjofe at gmail dot com
<glenjofe -at- gmail.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
#ifndef BOOST_ALIGN_DETAIL_ALIGNOF_HELPER_HPP
#define BOOST_ALIGN_DETAIL_ALIGNOF_HELPER_HPP
namespace boost {
namespace alignment {
namespace detail {
template<class T>
struct offset_object {
char offset;
struct alignof_helper {
char value;
T object;
};
} /* :detail */
} /* :alignment */
} /* :boost */
} /* .detail */
} /* .alignment */
} /* .boost */
#endif

View File

@ -1,6 +1,6 @@
/*
(c) 2014 Glen Joseph Fernandes
glenjofe at gmail dot com
<glenjofe -at- gmail.com>
Distributed under the Boost Software
License, Version 1.0.
@ -70,25 +70,25 @@ struct remove_cv {
};
template<class T>
struct padding {
char offset;
struct alignof_helper {
char value;
typename remove_cv<typename remove_all_extents<typename
remove_reference<T>::type>::type>::type object;
};
#define OFFSET(t, m) ((std::size_t)(&((t*)0)->m))
template<class T>
std::size_t offset()
std::size_t expect()
{
static padding<T> p = padding<T>();
return (char*)&p.object - &p.offset;
return OFFSET(alignof_helper<T>, object);
}
template<class T>
void test_type()
{
std::size_t result = boost::alignment::
alignment_of<T>::value;
BOOST_TEST_EQ(result, offset<T>());
BOOST_TEST_EQ(boost::alignment::
alignment_of<T>::value, expect<T>());
}
template<class T>