- 论坛徽章:
- 0
|
- #pragma warning(disable:4786)
- #include <conio.h>;
- #include <iostream>;
- #include <string>;
- #include <list>;
- #include <map>;
- #include <vector>;
- #include <algorithm>;
- #include <functional>;
- using namespace std;
- template <class _T>;
- struct empty_op
- {
- void operator()(_T val){}
- };
- template<class _T1,class _T2=empty_op<_T1>; >;
- struct clear_obj_1d
- {
- _T2 _op;
- void operator()(_T1 p)
- {
- _op(p);
- delete p;
- }
- };
- template<class _T1,class _T2=empty_op<_T1>; >;
- struct clear_obj_2d{
- _T2 _op;
- void operator()(_T1 val)
- {
- _op(val);
- delete val.second;
- }
- };
- template<class _T1,class _T2>;
- struct clear_1d{
- void operator()(_T1 p)
- {
- for_each(p->;begin(),p->;end(),_T2());
- }
- };
- template<class _T1,class _T2>;
- struct clear_2d{
- void operator()(_T1 p)
- {
- for_each(p.second->;begin(),p.second->;end(),_T2());
- }
- };
- typedef list<int *>; int_p_l;
- typedef list<int_p_l *>; int_p_l_p_l;
- typedef list<int_p_l_p_l *>; btl;
- int main()
- {
- btl l;
- for_each(l.begin(),l.end(),\
- clear_obj_1d<btl::value_type,\
- clear_1d<btl::value_type,\
- clear_obj_1d<int_p_l_p_l::value_type,
- clear_1d<int_p_l_p_l::value_type,
- clear_obj_1d<int_p_l::value_type
- >;
- >;
- >;
- >;
- >;());
- getch();
- return 0;
- }
复制代码 |
|