cppannotations/yo/stl/examples/deletertemplate.cc
Frank B. Brokken 2b428db412 WIP
git-svn-id: https://cppannotations.svn.sourceforge.net/svnroot/cppannotations/trunk@358 f6dd340e-d3f9-0310-b409-bdd246841980
2009-12-27 20:52:30 +00:00

20 lines
464 B
C++

#include <iostream>
#include <memory>
using namespace std;
template <typename Type, size_t size>
struct Deleter
{
void operator()(Type * ptr) const
{
for (size_t idx = 0; idx < size; ++idx)
delete ptr[idx];
delete ptr;
}
};
int main()
{
unique_ptr<int *, Deleter<int *, 10>> sp2(new int *[10]);
Deleter<int *, 10> &obj = sp2.get_deleter();
}