From 83dcab924db42fc470d35329cb11e92b6c246c1a Mon Sep 17 00:00:00 2001 From: Ansgar Burchardt <burchardt@igpm.rwth-aachen.de> Date: Wed, 22 Jul 2015 10:21:29 +0200 Subject: [PATCH] Remove fallback implementation for AlignmentOf Since fda5a9e02d04dc7f65e38bdf5ab7e26fbdf28951 AlignmentOf always uses std::alignment_of and the fallback implementation is no longer used. --- dune/common/alignment.hh | 64 ---------------------------------------- 1 file changed, 64 deletions(-) diff --git a/dune/common/alignment.hh b/dune/common/alignment.hh index 8d771668b..9c642d9e5 100644 --- a/dune/common/alignment.hh +++ b/dune/common/alignment.hh @@ -3,7 +3,6 @@ #ifndef DUNE_ALIGNMENT_HH #define DUNE_ALIGNMENT_HH -#include <cstddef> #include <type_traits> namespace Dune @@ -20,69 +19,6 @@ namespace Dune * @author Markus Blatt */ - namespace - { - - /** - * @brief Helper class to measure alignment requirement. - * @tparam T The type we want to measure the alignment requirement for. - */ - template<class T> - struct AlignmentStruct - { - char c; - T t; - void hack(); - }; - - /** - * @brief Helper class to measure alignment requirement. - * @tparam T The type we want to measure the alignment requirement for. - */ - template<class T, std::size_t N> - struct AlignmentHelper - { - enum { N2 = sizeof(AlignmentStruct<T>) - sizeof(T) - N }; - char padding1[N]; - T t; - char padding2[N2]; - }; - -#define ALIGNMENT_MODULO(a, b) (a % b == 0 ? \ - static_cast<std::size_t>(b) : \ - static_cast<std::size_t>(a % b)) -#define ALIGNMENT_MIN(a, b) (static_cast<std::size_t>(a) < \ - static_cast<std::size_t>(b) ? \ - static_cast<std::size_t>(a) : \ - static_cast<std::size_t>(b)) - /** @brief does the actual calculations. */ - template <class T, std::size_t N> - struct AlignmentTester - { - typedef AlignmentStruct<T> s; - typedef AlignmentHelper<T, N> h; - typedef AlignmentTester<T, N - 1> next; - enum - { - a1 = ALIGNMENT_MODULO(N , sizeof(T)), - a2 = ALIGNMENT_MODULO(h::N2 , sizeof(T)), - a3 = ALIGNMENT_MODULO(sizeof(h), sizeof(T)), - a = sizeof(h) == sizeof(s) ? ALIGNMENT_MIN(a1, a2) : a3, - result = ALIGNMENT_MIN(a, next::result) - }; - }; - - /** @brief does the actual calculations. */ - template <class T> - struct AlignmentTester<T, 0> - { - enum - { - result = ALIGNMENT_MODULO(sizeof(AlignmentStruct<T>), sizeof(T)) - }; - }; - } //end anonymous namespace - /** * @brief Calculates the alignment requirement of a type. * -- GitLab