]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/align/test/alignment_of_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / align / test / alignment_of_test.cpp
index 386667974d5ddd811ac5be7a4485cadcfdf7203e..7df84c6cd26bc7c4460318ca636f1d30ece27fc3 100644 (file)
@@ -1,16 +1,14 @@
 /*
-(c) 2014 Glen Joseph Fernandes
-<glenjofe -at- gmail.com>
+Copyright 2014 Glen Joseph Fernandes
+(glenjofe@gmail.com)
 
-Distributed under the Boost Software
-License, Version 1.0.
-http://boost.org/LICENSE_1_0.txt
+Distributed under the Boost Software License, Version 1.0.
+(http://www.boost.org/LICENSE_1_0.txt)
 */
 #include <boost/align/alignment_of.hpp>
 #include <boost/core/lightweight_test.hpp>
 #include <boost/config.hpp>
-
-#define OFFSET(t, m) ((std::size_t)(&((t*)0)->m))
+#include <cstddef>
 
 template<class T>
 struct remove_reference {
@@ -45,54 +43,39 @@ struct remove_all_extents<T[N]> {
 };
 
 template<class T>
-struct remove_const {
+struct remove_cv {
     typedef T type;
 };
 
 template<class T>
-struct remove_const<const T> {
+struct remove_cv<const T> {
     typedef T type;
 };
 
 template<class T>
-struct remove_volatile {
+struct remove_cv<volatile T> {
     typedef T type;
 };
 
 template<class T>
-struct remove_volatile<volatile T> {
+struct remove_cv<const volatile T> {
     typedef T type;
 };
 
 template<class T>
-struct remove_cv {
-    typedef typename remove_volatile<typename
-        remove_const<T>::type>::type type;
-};
-
-template<class T>
-struct alignof_helper {
+struct offset_value {
     char value;
     typename remove_cv<typename remove_all_extents<typename
         remove_reference<T>::type>::type>::type object;
 };
 
-template<class T>
-std::size_t result()
-{
-    return boost::alignment::alignment_of<T>::value;
-}
-
-template<class T>
-std::size_t expect()
-{
-    return OFFSET(alignof_helper<T>, object);
-}
-
 template<class T>
 void test_type()
 {
-    BOOST_TEST_EQ(result<T>(), expect<T>());
+    enum {
+        N = boost::alignment::alignment_of<T>::value
+    };
+    BOOST_TEST(offsetof(offset_value<T>, object) == N);
 }
 
 template<class T>
@@ -124,18 +107,12 @@ void test_cv()
 }
 
 template<class T>
-struct W1 {
-    T t;
-};
-
-template<class T>
-class W2 {
-public:
+struct Struct {
     T t;
 };
 
 template<class T>
-union W3 {
+union Union {
     T t;
 };
 
@@ -143,9 +120,8 @@ template<class T>
 void test()
 {
     test_cv<T>();
-    test_cv<W1<T> >();
-    test_cv<W2<T> >();
-    test_cv<W3<T> >();
+    test_cv<Struct<T> >();
+    test_cv<Union<T> >();
 }
 
 void test_integral()