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 long 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 <typename T> struct alignment_of;
00027 
00028 template <typename T>
00029 struct alignment_of_hack
00030 {
00031   char c;
00032   T t;
00033   alignment_of_hack();
00034 };
00035 
00036 template <unsigned A, unsigned S>
00037 struct alignment_logic
00038 {
00039   FLX_STATIC_CONSTANT(std::size_t, value = A < S ? A : S);
00040 };
00041 
00042 template< typename T >
00043 struct alignment_of
00044 {
00045   FLX_STATIC_CONSTANT(std::size_t, value =
00046     (alignment_logic<
00047       sizeof(alignment_of_hack<T>) - sizeof(T),
00048       sizeof(T)
00049     >::value));
00050 };
00051 
00052 template<std::size_t L, std::size_t A>
00053 struct aligned_storage
00054 {
00055   union type
00056   {
00057     unsigned char data_[ L ];
00058     typename type_with_alignment<A>::type align_;
00059   };
00060 };
00061 
00062 template<typename T>
00063 struct store_of
00064 {
00065   typedef typename aligned_storage<sizeof(T), alignment_of<T>::value>::type type;
00066 };
00067 
00068 // convert an rvalue to an lvalue
00069 template<typename T>
00070 T const &lvalue(T const &x)
00071 {
00072   return x;
00073 }
00074 
00075 // this reinterpret cast works with rvalues too
00076 template<typename T, typename U>
00077 T &reinterpret(U const &x) {
00078   return reinterpret_cast<T&>(const_cast<U&>(x));
00079 }
00080 #endif

Generated on Sat Nov 24 19:59:40 2007 for Felix by  doxygen 1.5.3-20071008