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

Generated on Mon Dec 24 07:59:57 2007 for Felix by  doxygen 1.5.4