ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

66 lines
1.5 KiB

  1. #ifndef BOOSTER_CHECKED_DELETE_H
  2. #define BOOSTER_CHECKED_DELETE_H
  3. //
  4. // boost/checked_delete.hpp
  5. //
  6. // Copyright (c) 2002, 2003 Peter Dimov
  7. // Copyright (c) 2003 Daniel Frey
  8. // Copyright (c) 2003 Howard Hinnant
  9. //
  10. // Distributed under the Boost Software License, Version 1.0. (See
  11. // accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. //
  14. // See http://www.boost.org/libs/utility/checked_delete.html for documentation.
  15. //
  16. namespace booster
  17. {
  18. /// \cond INTERNAL
  19. // verify that types are complete for increased safety
  20. template<class T> inline void checked_delete(T * x)
  21. {
  22. // intentionally complex - simplification causes regressions
  23. typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
  24. (void) sizeof(type_must_be_complete);
  25. delete x;
  26. }
  27. template<class T> inline void checked_array_delete(T * x)
  28. {
  29. typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
  30. (void) sizeof(type_must_be_complete);
  31. delete [] x;
  32. }
  33. template<class T> struct checked_deleter
  34. {
  35. typedef void result_type;
  36. typedef T * argument_type;
  37. void operator()(T * x) const
  38. {
  39. // boost:: disables ADL
  40. booster::checked_delete(x);
  41. }
  42. };
  43. template<class T> struct checked_array_deleter
  44. {
  45. typedef void result_type;
  46. typedef T * argument_type;
  47. void operator()(T * x) const
  48. {
  49. booster::checked_array_delete(x);
  50. }
  51. };
  52. /// \endcond
  53. } // namespace boost
  54. #endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED