3#ifndef DUNE_ALIGNMENT_HH 
    4#define DUNE_ALIGNMENT_HH 
   31    struct AlignmentStruct
 
   42    template<
class T, std::
size_t N>
 
   43    struct AlignmentHelper
 
   45      enum { N2 = 
sizeof(AlignmentStruct<T>) - 
sizeof(T) - N };
 
   51#define ALIGNMENT_MODULO(a, b)   (a % b == 0 ? \ 
   52                                  static_cast<std::size_t>(b) : \ 
   53                                  static_cast<std::size_t>(a % b)) 
   54#define ALIGNMENT_MIN(a, b)      (static_cast<std::size_t>(a) <   \ 
   55                                  static_cast<std::size_t>(b) ? \ 
   56                                  static_cast<std::size_t>(a) : \ 
   57                                  static_cast<std::size_t>(b)) 
   59    template <
class T, std::
size_t N>
 
   60    struct AlignmentTester
 
   62      typedef AlignmentStruct<T>        s;
 
   63      typedef AlignmentHelper<T, N>     h;
 
   64      typedef AlignmentTester<T, N - 1> next;
 
   67        a1       = ALIGNMENT_MODULO(N        , 
sizeof(T)),
 
   68        a2       = ALIGNMENT_MODULO(h::N2    , 
sizeof(T)),
 
   69        a3       = ALIGNMENT_MODULO(
sizeof(h), 
sizeof(T)),
 
   70        a        = 
sizeof(h) == 
sizeof(s) ? ALIGNMENT_MIN(a1, a2) : a3,
 
   71        result   = ALIGNMENT_MIN(a, next::result)
 
   77    struct AlignmentTester<T, 0>
 
   81        result = ALIGNMENT_MODULO(
sizeof(AlignmentStruct<T>), 
sizeof(T))
 
  101      value = std::alignment_of<T>::value
 
Dune namespace.
Definition: alignment.hh:10
 
Calculates the alignment requirement of a type.
Definition: alignment.hh:96
 
@ value
The alignment requirement.
Definition: alignment.hh:101