99# include < boost/python/detail/char_array.hpp>
1010# include < boost/mpl/select_type.hpp>
1111# include < boost/type_traits/same_traits.hpp>
12- # include < boost/type_traits/alignment_traits.hpp>
1312# include < boost/type_traits/transform_traits.hpp>
1413# include < boost/static_assert.hpp>
1514# include < boost/python/converter/from_python_stage1_data.hpp>
@@ -24,18 +23,10 @@ namespace boost { namespace python { namespace converter {
2423
2524namespace detail
2625{
27- template <class T > struct referent_alignment ;
2826 template <class T > struct referent_size ;
2927
3028# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
3129
32- template <class T >
33- struct referent_alignment <T&>
34- {
35- BOOST_STATIC_CONSTANT (
36- std::size_t , value = alignment_of<T>::value);
37- };
38-
3930 template <class T >
4031 struct referent_size <T&>
4132 {
@@ -45,26 +36,6 @@ namespace detail
4536
4637# else
4738
48- template <class U >
49- struct alignment_chars
50- {
51- BOOST_STATIC_CONSTANT (
52- std::size_T, n = alignment_of<U>::value);
53- char elements[n + 1 ];
54- };
55-
56- template <class T > struct referent_alignment
57- {
58- template <class U >
59- static alignment_chars<U> helper (U&);
60-
61- static T t;
62-
63- BOOST_STATIC_CONSTANT (
64- std::size_t , value = sizeof (helper(t).elements) - 1 );
65- };
66-
67-
6839 template <class T > struct referent_size
6940 {
7041 static T f ();
@@ -82,24 +53,12 @@ namespace detail
8253 char , short , int , long , float , double , long double \
8354 , void *, function_ptr, member_ptr, member_function_ptr))
8455
85- # define BOOST_PYTHON_CHOOSE_LOWER_ALIGNMENT (R,P,I,T ) \
86- typename mpl::select_type< \
87- alignment_of<T>::value <= target, T, char >::type BOOST_PP_CAT (t,I);
88-
8956# define BOOST_PYTHON_CHOOSE_LOWER_SIZE (R,P,I,T ) \
9057 typename mpl::select_type< \
9158 sizeof (T) <= target, T, char >::type BOOST_PP_CAT (t,I);
9259
9360# define BOOST_PYTHON_CHOOSE_T (R,P,I,T ) T BOOST_PP_CAT (t,I);
9461
95- template <std::size_t target>
96- union lower_alignment
97- {
98- BOOST_PP_LIST_FOR_EACH_I (
99- BOOST_PYTHON_CHOOSE_LOWER_ALIGNMENT
100- , ignored, BOOST_PYTHON_ALIGNMENT_TYPES)
101- };
102-
10362 template <std::size_t target>
10463 union lower_size
10564 {
@@ -108,13 +67,6 @@ namespace detail
10867 , ignored, BOOST_PYTHON_ALIGNMENT_TYPES)
10968 };
11069
111- union max_align
112- {
113- BOOST_PP_LIST_FOR_EACH_I (
114- BOOST_PYTHON_CHOOSE_T
115- , ignored, BOOST_PYTHON_ALIGNMENT_TYPES)
116- };
117-
11870 template <class Align , std::size_t size>
11971 union aligned_storage
12072 {
@@ -125,35 +77,7 @@ namespace detail
12577 template <class Reference >
12678 struct referent_storage
12779 {
128- BOOST_STATIC_CONSTANT (std::size_t , target = referent_alignment<Reference>::value);
129- typedef lower_alignment<target> t1;
130-
131- BOOST_STATIC_CONSTANT (bool , t1_aligned =
132- (alignment_of<t1>::value >= target)
133- & (alignment_of<t1>::value % target == 0 ));
134-
135- typedef lower_size<referent_size<Reference>::value> t2;
136-
137- BOOST_STATIC_CONSTANT (bool , t2_aligned =
138- (alignment_of<t2>::value >= target)
139- & (alignment_of<t2>::value % target == 0 ));
140-
141-
142- typedef typename mpl::select_type<
143- t1_aligned
144- , t1
145- , typename mpl::select_type<
146- t2_aligned
147- , t2
148- , max_align
149- >::type
150- >::type align_t ;
151-
152- BOOST_STATIC_CONSTANT (std::size_t , found = alignment_of<align_t >::value);
153-
154- BOOST_STATIC_ASSERT (found >= target);
155- BOOST_STATIC_ASSERT (found % target == 0 );
156-
80+ typedef lower_size<referent_size<Reference>::value> align_t ;
15781 typedef aligned_storage<align_t ,referent_size<Reference>::value> type;
15882 };
15983}
0 commit comments