#include <iostream>
#include <vector>
#include <string.h>
#include <memory>
using  namespace std;

template< typename T >
struct array_deleter
{
  void operator ()(T const * x)  { delete[] x; }
};

class MemoryPage
{
    size_t size;
    std::shared_ptr<char> buf;

    public:
  explicit MemoryPage(int sz=8)
  : size(sz) 
  , buf (new char[sz], array_deleter<char>())
  {
       std::cout<<"buffer='" << buf<<"'"<<" start address "<<(void *)buf.get()<<std::endl;
       
       // std::cout<<"sz=" << size<<std::endl;
       // for(size_t i=0;i <size; i++){
       //    buf[i]='a'+32/sz - 1 ;
       // }
     }
    
    // ----- Деструктор вообще не нужон --------
    // ~MemoryPage(){
    //     if(buf[0]!=null ) {
    //      std::cout<<"buffer='" << buf<<"'"<<" delete from  address "<<(void *)buf.get()<<"\t"<< size<<" bytes "<<std::endl;
    //     delete[] buf;
    //    }
    //  }
  };
using namespace std;
int main()
{
    vector<MemoryPage> vm;
    MemoryPage memoryPage(1024);
    vm.push_back(MemoryPage(32));
    vm.push_back(MemoryPage(16));
    vm.push_back(MemoryPage(8));
    cout<<" destroy vector "<< endl;
}
