diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:21:29 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 15:21:29 +0200 |
commit | bada6666c70977a058755ccf232e7d67b24adeed (patch) | |
tree | 1e92d50cebce96abaf9bce19e36026c47f77b9ba /xsd/libxsd/xsd/cxx/auto-array.hxx | |
parent | eaf34adcbd8095bc6d1f3371b1227f654c7b19fc (diff) |
New upstream release
Diffstat (limited to 'xsd/libxsd/xsd/cxx/auto-array.hxx')
-rw-r--r-- | xsd/libxsd/xsd/cxx/auto-array.hxx | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/xsd/libxsd/xsd/cxx/auto-array.hxx b/xsd/libxsd/xsd/cxx/auto-array.hxx index 2b4e100..584785e 100644 --- a/xsd/libxsd/xsd/cxx/auto-array.hxx +++ b/xsd/libxsd/xsd/cxx/auto-array.hxx @@ -1,11 +1,16 @@ // file : xsd/cxx/auto-array.hxx -// author : Boris Kolpackov <boris@codesynthesis.com> -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_AUTO_ARRAY_HXX #define XSD_CXX_AUTO_ARRAY_HXX +#include <xsd/cxx/config.hxx> // XSD_CXX11 + +#ifdef XSD_CXX11 +# error use std::unique_ptr instead of non-standard auto_array +#endif + #include <cstddef> // std::size_t namespace xsd @@ -13,20 +18,20 @@ namespace xsd namespace cxx { template <typename T> - struct std_deallocator + struct std_array_deleter { void - deallocate (T* p) + operator() (T* p) const { delete[] p; } }; // Simple automatic array. The second template parameter is - // an optional deallocator type. If not specified, delete[] + // an optional deleter type. If not specified, delete[] // is used. // - template <typename T, typename D = std_deallocator<T> > + template <typename T, typename D = std_array_deleter<T> > struct auto_array { auto_array (T a[]) @@ -34,7 +39,7 @@ namespace xsd { } - auto_array (T a[], D& d) + auto_array (T a[], const D& d) : a_ (a), d_ (&d) { } @@ -42,7 +47,7 @@ namespace xsd ~auto_array () { if (d_ != 0) - d_->deallocate (a_); + (*d_) (a_); else delete[] a_; } @@ -73,7 +78,7 @@ namespace xsd if (a_ != a) { if (d_ != 0) - d_->deallocate (a_); + (*d_) (a_); else delete[] a_; @@ -100,7 +105,7 @@ namespace xsd private: T* a_; - D* d_; + const D* d_; }; template <typename T, typename D> |