[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]
![]() |
vigra/memory.hxx | ![]() |
---|
00001 /************************************************************************/ 00002 /* */ 00003 /* Copyright 2002-2003 by Ullrich Koethe, Hans Meine */ 00004 /* Cognitive Systems Group, University of Hamburg, Germany */ 00005 /* */ 00006 /* This file is part of the VIGRA computer vision library. */ 00007 /* ( Version 1.3.2, Jan 27 2005 ) */ 00008 /* You may use, modify, and distribute this software according */ 00009 /* to the terms stated in the LICENSE file included in */ 00010 /* the VIGRA distribution. */ 00011 /* */ 00012 /* The VIGRA Website is */ 00013 /* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */ 00014 /* Please direct questions, bug reports, and contributions to */ 00015 /* koethe@informatik.uni-hamburg.de */ 00016 /* */ 00017 /* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */ 00018 /* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */ 00019 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ 00020 /* */ 00021 /************************************************************************/ 00022 00023 #ifndef VIGRA_MEMORY_HXX 00024 #define VIGRA_MEMORY_HXX 00025 00026 #include <vigra/metaprogramming.hxx> 00027 00028 namespace vigra { namespace detail { 00029 00030 template <class T> 00031 void destroy_n(T * /* p */, int /* n */, VigraTrueType /* isPOD */) 00032 { 00033 } 00034 00035 template <class T> 00036 void destroy_n(T * p, int n, VigraFalseType /* isPOD */) 00037 { 00038 T * end = p + n; 00039 for(; p != end; ++p) 00040 p->~T(); 00041 } 00042 00043 template <class T> 00044 void destroy_n(T * p, int n) 00045 { 00046 destroy_n(p, n, typename TypeTraits<T>::isPOD()); 00047 } 00048 00049 /********************************************************************/ 00050 00051 // g++ 2.95 has std::destroy() in the STL 00052 #if !defined(__GNUC__) || __GNUC__ >= 3 00053 00054 template <class T> 00055 void destroy(T * p, VigraTrueType /* isPOD */) 00056 { 00057 } 00058 00059 template <class T> 00060 void destroy(T * p, VigraFalseType /* isPOD */) 00061 { 00062 p->~T(); 00063 } 00064 00065 template <class T> 00066 void destroy(T * p) 00067 { 00068 destroy(p, typename TypeTraits<T>::isPOD()); 00069 } 00070 00071 #else 00072 00073 } } // namespace vigra::detail 00074 00075 #include <memory> 00076 00077 namespace vigra { namespace detail { 00078 00079 using std::destroy; 00080 00081 #endif 00082 00083 } } // namespace vigra::detail 00084 00085 #endif // VIGRA_MEMORY_HXX
© Ullrich Köthe (koethe@informatik.uni-hamburg.de) |
html generated using doxygen and Python
|