练习12.26:用allocator重写第427页中的程序。
/*
*2016/1/25
*练习12.26:用allocator重写第427页中的程序。
*说明:无
*作者:Nick Feng
*邮箱:NickGreen23@163.com
*
*/
#include <iostream>
#include <memory>
using namespace std;
int main()
{
int n = 3;
allocator<string> alloc;
auto p = alloc.allocate(n);
string s;
auto q = p;
while(cin >> s && q != p +n)
{
alloc.construct(q++, s);
}
while (q != p)
{
cout << *p<< " ";
alloc.destroy(--q);
}
cout << endl;
return 0;
}