Docs GODI Archive
Projects Blog Link DB

Search GODI:


More options
File lib/felix/rtl/flx_meta.hpp GODI Package apps-felix
 
   flx_meta.hpp  
#line 16 "lpsrc/flx_rtl.ipk"
#ifndef FLX_META
#define FLX_META
// taken from BOOST
#line 21 "lpsrc/flx_rtl.ipk"
#define FLX_HAVE_INCLASS_MEMBER_INITIALIZATION
#line 21 "lpsrc/flx_rtl.ipk"
#ifdef FLX_HAVE_INCLASS_MEMBER_INITIALIZATION
#  define FLX_STATIC_CONSTANT(type, assignment) static const type assignment
#else
#  define FLX_STATIC_CONSTANT(type, assignment) enum { assignment }
#endif

#include <cstddef>

template <std::size_t> struct type_with_alignment;
#line 34 "lpsrc/flx_rtl.ipk"
template <> struct type_with_alignment<1>{ typedef char type; };
#line 34 "lpsrc/flx_rtl.ipk"
template <> struct type_with_alignment<2>{ typedef short type; };
#line 34 "lpsrc/flx_rtl.ipk"
template <> struct type_with_alignment<4>{ typedef void* type; };
#line 34 "lpsrc/flx_rtl.ipk"
template <typename T> struct alignment_of;

template <typename T>
struct alignment_of_hack
{
  char c;
  T t;
  alignment_of_hack();
};

template <unsigned A, unsigned S>
struct alignment_logic
{
  FLX_STATIC_CONSTANT(std::size_t, value = A < S ? A : S);
};

template< typename T >
struct alignment_of
{
  FLX_STATIC_CONSTANT(std::size_t, value =
    (alignment_logic<
      sizeof(alignment_of_hack<T>) - sizeof(T),
      sizeof(T)
    >::value));
};

template<std::size_t L, std::size_t A>
struct aligned_storage
{
  union type
  {
    unsigned char data_[ L ];
    typename type_with_alignment<A>::type align_;
  };
};

template<typename T>
struct store_of
{
  typedef typename aligned_storage<sizeof(T), alignment_of<T>::value>::type type;
};

// convert an rvalue to an lvalue
template<typename T>
T const &lvalue(T const &x)
{
  return x;
}

// this reinterpret cast works with rvalues too
template<typename T, typename U>
T &reinterpret(U const &x) {
  return reinterpret_cast<T&>(const_cast<U&>(x));
}
#endif


This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml