epoc32/include/stdapis/boost/checked_delete.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/checked_delete.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,69 @@
     1.4 +#ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
     1.5 +#define BOOST_CHECKED_DELETE_HPP_INCLUDED
     1.6 +
     1.7 +// MS compatible compilers support #pragma once
     1.8 +
     1.9 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
    1.10 +# pragma once
    1.11 +#endif
    1.12 +
    1.13 +//
    1.14 +//  boost/checked_delete.hpp
    1.15 +//
    1.16 +//  Copyright (c) 2002, 2003 Peter Dimov
    1.17 +//  Copyright (c) 2003 Daniel Frey
    1.18 +//  Copyright (c) 2003 Howard Hinnant
    1.19 +//
    1.20 +//  Distributed under the Boost Software License, Version 1.0. (See
    1.21 +//  accompanying file LICENSE_1_0.txt or copy at
    1.22 +//  http://www.boost.org/LICENSE_1_0.txt)
    1.23 +//
    1.24 +//  See http://www.boost.org/libs/utility/checked_delete.html for documentation.
    1.25 +//
    1.26 +
    1.27 +namespace boost
    1.28 +{
    1.29 +
    1.30 +// verify that types are complete for increased safety
    1.31 +
    1.32 +template<class T> inline void checked_delete(T * x)
    1.33 +{
    1.34 +    // intentionally complex - simplification causes regressions
    1.35 +    typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
    1.36 +    (void) sizeof(type_must_be_complete);
    1.37 +    delete x;
    1.38 +}
    1.39 +
    1.40 +template<class T> inline void checked_array_delete(T * x)
    1.41 +{
    1.42 +    typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
    1.43 +    (void) sizeof(type_must_be_complete);
    1.44 +    delete [] x;
    1.45 +}
    1.46 +
    1.47 +template<class T> struct checked_deleter
    1.48 +{
    1.49 +    typedef void result_type;
    1.50 +    typedef T * argument_type;
    1.51 +
    1.52 +    void operator()(T * x) const
    1.53 +    {
    1.54 +        // boost:: disables ADL
    1.55 +        boost::checked_delete(x);
    1.56 +    }
    1.57 +};
    1.58 +
    1.59 +template<class T> struct checked_array_deleter
    1.60 +{
    1.61 +    typedef void result_type;
    1.62 +    typedef T * argument_type;
    1.63 +
    1.64 +    void operator()(T * x) const
    1.65 +    {
    1.66 +        boost::checked_array_delete(x);
    1.67 +    }
    1.68 +};
    1.69 +
    1.70 +} // namespace boost
    1.71 +
    1.72 +#endif  // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED