flx_meta.hpp

00001 #line 138 "./lpsrc/flx_rtl.pak"
00002 #ifndef __FLX_META_H__
00003 #define __FLX_META_H__
00004 // taken from BOOST
00005 #line 146 "./lpsrc/flx_rtl.pak"
00006 #define FLX_HAVE_INCLASS_MEMBER_INITIALIZATION 1
00007 #line 146 "./lpsrc/flx_rtl.pak"
00008 #if FLX_HAVE_INCLASS_MEMBER_INITIALIZATION
00009 #  define FLX_STATIC_CONSTANT(type, assignment) static const type assignment
00010 #else
00011 #  define FLX_STATIC_CONSTANT(type, assignment) enum { assignment }
00012 #endif
00013 
00014 #include <cstddef>
00015 
00016 template <std::size_t> struct type_with_alignment;
00017 #line 159 "./lpsrc/flx_rtl.pak"
00018 template <> struct type_with_alignment<8>{ typedef double type; };
00019 #line 159 "./lpsrc/flx_rtl.pak"
00020 template <> struct type_with_alignment<1>{ typedef char type; };
00021 #line 159 "./lpsrc/flx_rtl.pak"
00022 template <> struct type_with_alignment<2>{ typedef short type; };
00023 #line 159 "./lpsrc/flx_rtl.pak"
00024 template <> struct type_with_alignment<4>{ typedef void* type; };
00025 #line 159 "./lpsrc/flx_rtl.pak"
00026 template <> struct type_with_alignment<16>{ typedef long double type; };
00027 #line 159 "./lpsrc/flx_rtl.pak"
00028 template <typename T> struct alignment_of;
00029 
00030 template <typename T>
00031 struct alignment_of_hack
00032 {
00033   char c;
00034   T t;
00035   alignment_of_hack();
00036 };
00037 
00038 template <unsigned A, unsigned S>
00039 struct alignment_logic
00040 {
00041   FLX_STATIC_CONSTANT(std::size_t, value = A < S ? A : S);
00042 };
00043 
00044 template< typename T >
00045 struct alignment_of
00046 {
00047   FLX_STATIC_CONSTANT(std::size_t, value =
00048     (alignment_logic<
00049       sizeof(alignment_of_hack<T>) - sizeof(T),
00050       sizeof(T)
00051     >::value));
00052 };
00053 
00054 template<std::size_t L, std::size_t A>
00055 struct aligned_storage
00056 {
00057   union type
00058   {
00059     unsigned char data_[ L ];
00060     typename type_with_alignment<A>::type align_;
00061   };
00062 };
00063 
00064 template<typename T>
00065 struct store_of
00066 {
00067   typedef typename aligned_storage<sizeof(T), alignment_of<T>::value>::type type;
00068 };
00069 
00070 // convert an rvalue to an lvalue
00071 template<typename T>
00072 T const &lvalue(T const &x)
00073 {
00074   return x;
00075 }
00076 
00077 // this reinterpret cast works with rvalues too
00078 template<typename T, typename U>
00079 T &reinterpret(U const &x) {
00080   return reinterpret_cast<T&>(const_cast<U&>(x));
00081 }
00082 #endif

Generated on Fri Jun 8 02:03:49 2007 for Felix by  doxygen 1.5.2