Boost logo

Boost Users :

From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-01-18 17:51:35


Hi,

I was wondering it is currently possible to give ptr_vector a custom
deleter? This could simply be in the form of a functor. If this feature does
not exist, would it be hard to add? For example, you could do this:

namespace boost
{
    namespace detail
    {
        template< typename t_type >
        struct default_deleter
        {
            void operator() ( t_type* ptr )
            {
                delete ptr;
            }
        };
    }

    template<
        typename t_type,
        typename t_deleter = detail::default_deleter<t_type>
>
    class ptr_vector
    {
    private:
        std::vector<t_type*> m_pointers;

    public:
        ~ptr_vector()
        {
            std::for_each( m_pointers.begin(), m_pointers.end(), t_deleter()
);
        }
    };
}



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net