/* -*- C++ -*- */
/*************************************************************************
 * Copyright(c) 1995~2005  Masaharu Goto (cint@pcroot.cern.ch)
 *
 * For the licensing terms see the file COPYING
 *
 ************************************************************************/
#ifndef _AUTOCONTAINER_H
#define _AUTOCONTAINER_H

#include <algorithm>
#include <functional>

using namespace std;

template <class T>
struct DeleteObj : std::unary_function<T,T> {
  T operator()(const T& x) const {delete x; return 0;}
};

template<class pObjBase,class Container>
struct AutoContainer : public Container {
  ~AutoContainer()
    //{for_each(rbegin(),rend(),DeleteObj<pObjBase>());}
    {transform(rbegin(),rend(),rbegin(),DeleteObj<pObjBase>());}
};

#endif
