variant_allocator.h
Go to the documentation of this file.
00001 
00025 #ifndef _VARIANT_ALLOCATOR_H_
00026 #define _VARIANT_ALLOCATOR_H_
00027 
00028 #include <limits>
00029 #include "bcap_core/dn_common.h"
00030 
00031 template<class T> class VariantAllocator
00032 {
00033 public:
00034   typedef size_t  size_type;
00035   typedef ptrdiff_t difference_type;
00036   typedef T* pointer;
00037   typedef const T* const_pointer;
00038   typedef T& reference;
00039   typedef const T& const_reference;
00040   typedef T value_type;
00041 
00042   template <class U>
00043   struct rebind
00044   {
00045     typedef VariantAllocator<U> other;
00046   };
00047 
00048   pointer allocate(size_type num, const void* hint = 0)
00049   {
00050     return (pointer)( ::operator new(num * sizeof(T)));
00051   }
00052 
00053   void construct(pointer p, const T& value)
00054   {
00055     VariantInit(p);
00056     VariantCopy(p, &value);
00057   }
00058 
00059   pointer address(reference value) const
00060   { 
00061     return &value; 
00062   }
00063 
00064   const_pointer address(const_reference value) const
00065   { 
00066     return &value;
00067   }
00068 
00069   void destroy(pointer p)
00070   {
00071     VariantClear(p);
00072   }
00073 
00074   void deallocate(pointer p, size_type n)
00075   {
00076     ::operator delete((void*)p);
00077   }
00078 
00079   size_type max_size() const throw()
00080   {
00081     return std::numeric_limits<size_t>::max() / sizeof(T);
00082   }
00083 };
00084 
00085 #endif


bcap_service
Author(s): DENSO WAVE INCORPORATED
autogenerated on Thu Jun 6 2019 21:00:08