[ 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.4.0, Dec 21 2005 )                                    */
    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 /*        koethe@informatik.uni-hamburg.de          or                  */
    00012 /*        vigra@kogs1.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 <vigra/metaprogramming.hxx>
    00042
    00043 namespace vigra { namespace detail {
    00044
    00045 template <class T>
    00046 void destroy_n(T * /* p */, int /* n */, VigraTrueType /* isPOD */)
    00047 {
    00048 }
    00049
    00050 template <class T>
    00051 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 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 void destroy(T * p, VigraTrueType /* isPOD */)
    00071 {
    00072 }
    00073
    00074 template <class T>
    00075 void destroy(T * p, VigraFalseType /* isPOD */)
    00076 {
    00077     p->~T();
    00078 }
    00079
    00080 template <class T>
    00081 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 (koethe@informatik.uni-hamburg.de) Cognitive Systems Group, University of Hamburg, Germany | html generated using doxygen and Python VIGRA 1.4.0 (21 Dec 2005)