/* * Copyright (c) 2012-2014 Glen Joseph Fernandes * glenfe at live dot com * * Distributed under the Boost Software License, * Version 1.0. (See accompanying file LICENSE_1_0.txt * or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_SMART_PTR_DETAIL_ARRAY_DELETER_HPP #define BOOST_SMART_PTR_DETAIL_ARRAY_DELETER_HPP #include #include namespace boost { namespace detail { template struct array_count_base; template struct array_count_base { array_count_base(std::size_t size_) : size(size_) { } std::size_t size; }; template struct array_count_base { enum { size = N }; }; template class array_deleter : array_count_base { using array_count_base::size; public: typedef typename array_inner::type type; array_deleter() : object(0) { } array_deleter(std::size_t size_) : array_count_base(size_), object(0) { } ~array_deleter() { if (object) { array_destroy(object, size); } } void init(type* memory) { array_init(memory, size); object = memory; } template void init(type* memory, const type* value) { array_init(memory, size, value); object = memory; } void noinit(type* memory) { array_noinit(memory, size); object = memory; } void operator()(const void*) { if (object) { array_destroy(object, size); object = 0; } } private: type* object; }; } } #endif