VIGRA - VIGRA: vigra/memory.hxx Source File

[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | 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.6.0, Aug 13 2008 )                                    */
    00008 /*    The VIGRA Website is                                              */
    00009 /*        http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/      */
    00010 /*    Please direct questions, bug reports, and contributions to        */
    00011 /*        ullrich.koethe@iwr.uni-heidelberg.de    or                    */
    00012 /*        vigra@informatik.uni-hamburg.de                               */
    00013 /*                                                                      */
    00014 /*    Permission is hereby granted, free of charge, to any person       */
    00015 /*    obtaining a copy of this software and associated documentation    */
    00016 /*    files (the "Software"), to deal in the Software without           */
    00017 /*    restriction, including without limitation the rights to use,      */
    00018 /*    copy, modify, merge, publish, distribute, sublicense, and/or      */
    00019 /*    sell copies of the Software, and to permit persons to whom the    */
    00020 /*    Software is furnished to do so, subject to the following          */
    00021 /*    conditions:                                                       */
    00022 /*                                                                      */
    00023 /*    The above copyright notice and this permission notice shall be    */
    00024 /*    included in all copies or substantial portions of the             */
    00025 /*    Software.                                                         */
    00026 /*                                                                      */
    00027 /*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND    */
    00028 /*    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES   */
    00029 /*    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND          */
    00030 /*    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT       */
    00031 /*    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,      */
    00032 /*    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      */
    00033 /*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR     */
    00034 /*    OTHER DEALINGS IN THE SOFTWARE.                                   */
    00035 /*                                                                      */
    00036 /************************************************************************/
    00037
    00038 #ifndef VIGRA_MEMORY_HXX
    00039 #define VIGRA_MEMORY_HXX
    00040
    00041 #include "metaprogramming.hxx"
    00042
    00043 namespace vigra { namespace detail {
    00044
    00045 template <class T>
    00046 inline void destroy_n(T * /* p */, int /* n */, VigraTrueType /* isPOD */)
    00047 {
    00048 }
    00049
    00050 template <class T>
    00051 inline void destroy_n(T * p, int n, VigraFalseType /* isPOD */)
    00052 {
    00053     T * end = p + n;
    00054     for(; p != end; ++p)
    00055         p->~T();
    00056 }
    00057
    00058 template <class T>
    00059 inline void destroy_n(T * p, int n)
    00060 {
    00061     destroy_n(p, n, typename TypeTraits<T>::isPOD());
    00062 }
    00063
    00064 /********************************************************************/
    00065
    00066 // g++ 2.95 has std::destroy() in the STL
    00067 #if !defined(__GNUC__) ||  __GNUC__ >= 3
    00068
    00069 template <class T>
    00070 inline void destroy(T * p, VigraTrueType /* isPOD */)
    00071 {
    00072 }
    00073
    00074 template <class T>
    00075 inline void destroy(T * p, VigraFalseType /* isPOD */)
    00076 {
    00077     p->~T();
    00078 }
    00079
    00080 template <class T>
    00081 inline void destroy(T * p)
    00082 {
    00083     destroy(p, typename TypeTraits<T>::isPOD());
    00084 }
    00085
    00086 #else
    00087
    00088 } } // namespace vigra::detail
    00089
    00090 #include <memory>
    00091
    00092 namespace vigra { namespace detail {
    00093
    00094 using std::destroy;
    00095
    00096 #endif
    00097
    00098 } } // namespace vigra::detail
    00099
    00100 #endif // VIGRA_MEMORY_HXX

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python VIGRA 1.6.0 (13 Aug 2008)