用Traits进行类别推导,将类别选择工作放到编译期进行,利用重载提高效率。
      下面的type_traits.h是我直接从SGI STL里Copy出来的。。。
		
				 #ifndef TYPE_TRAITS_H
				#ifndef TYPE_TRAITS_H
 #define
				 TYPE_TRAITS_H
				#define
				 TYPE_TRAITS_H
				
						
						 
						
						 //
				为了了重载确定那些类弄型是不用析构的SGI STl用了type_traits
				
				//
				为了了重载确定那些类弄型是不用析构的SGI STl用了type_traits
 //
				并将一些Scale type进行特例化
				//
				并将一些Scale type进行特例化
				
						
						 
						 struct
				 __true_type
				
				struct
				 __true_type 
				
						 {
				
				
						{
 }
				
				;
}
				
				;


 struct
				 __false_type
				struct
				 __false_type 
				
						 {
				
				
						{
 }
				
				;
}
				
				;

 template 
				<
				class
				 _Tp
				>
template 
				<
				class
				 _Tp
				>
				
						
						 
						 struct
				 __type_traits
				
				struct
				 __type_traits 
				
						 {
				
				
						{ 
 typedef __true_type     this_dummy_member_must_be_first;
   typedef __true_type     this_dummy_member_must_be_first;

 typedef __false_type    has_trivial_default_constructor;
   typedef __false_type    has_trivial_default_constructor;
 typedef __false_type    has_trivial_copy_constructor;
   typedef __false_type    has_trivial_copy_constructor;
 typedef __false_type    has_trivial_assignment_operator;
   typedef __false_type    has_trivial_assignment_operator;
 typedef __false_type    has_trivial_destructor;
   typedef __false_type    has_trivial_destructor;
 typedef __false_type    is_POD_type;
   typedef __false_type    is_POD_type;
 }
				
				;
}
				
				;

 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				bool
				>
				
				struct
				 __type_traits
				<
				bool
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				char
				>
 
				struct
				 __type_traits
				<
				char
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				signed 
				char
				>
 
				struct
				 __type_traits
				<
				signed 
				char
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				unsigned 
				char
				>
 
				struct
				 __type_traits
				<
				unsigned 
				char
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				wchar_t
				>
 
				struct
				 __type_traits
				<
				wchar_t
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;

 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				short
				>
 
				struct
				 __type_traits
				<
				short
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				unsigned 
				short
				>
 
				struct
				 __type_traits
				<
				unsigned 
				short
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				int
				>
 
				struct
				 __type_traits
				<
				int
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				unsigned 
				int
				>
 
				struct
				 __type_traits
				<
				unsigned 
				int
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				long
				>
 
				struct
				 __type_traits
				<
				long
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				unsigned 
				long
				>
 
				struct
				 __type_traits
				<
				unsigned 
				long
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;

 #ifdef __STL_LONG_LONG
#ifdef __STL_LONG_LONG
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				long
				 
				long
				>
 
				struct
				 __type_traits
				<
				long
				 
				long
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;


 struct
				 __type_traits
				<
				unsigned 
				long
				 
				long
				>
 
				struct
				 __type_traits
				<
				unsigned 
				long
				 
				long
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;

 #endif
				 /* __STL_LONG_LONG */
				#endif
				 /* __STL_LONG_LONG */
				
						
						 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				float
				>
 
				struct
				 __type_traits
				<
				float
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				double
				>
 
				struct
				 __type_traits
				<
				double
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				long
				 
				double
				>
 
				struct
				 __type_traits
				<
				long
				 
				double
				>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;

 template 
				<
				class
				 _Tp
				>
template 
				<
				class
				 _Tp
				>
				
						
						 
						 struct
				 __type_traits
				<
				_Tp
				*>
				
				struct
				 __type_traits
				<
				_Tp
				*>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				char
				*>
 
				struct
				 __type_traits
				<
				char
				*>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				signed 
				char
				*>
 
				struct
				 __type_traits
				<
				signed 
				char
				*>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				unsigned 
				char
				*>
 
				struct
				 __type_traits
				<
				unsigned 
				char
				*>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				const
				 
				char
				*>
 
				struct
				 __type_traits
				<
				const
				 
				char
				*>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				const
				 signed 
				char
				*>
 
				struct
				 __type_traits
				<
				const
				 signed 
				char
				*>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;
 template
				<>
template
				<>
				
						
						 
						 struct
				 __type_traits
				<
				const
				 unsigned 
				char
				*>
 
				struct
				 __type_traits
				<
				const
				 unsigned 
				char
				*>
				 
				
						 {
				
				
						{
 typedef __true_type    has_trivial_default_constructor;
   typedef __true_type    has_trivial_default_constructor;
 typedef __true_type    has_trivial_copy_constructor;
   typedef __true_type    has_trivial_copy_constructor;
 typedef __true_type    has_trivial_assignment_operator;
   typedef __true_type    has_trivial_assignment_operator;
 typedef __true_type    has_trivial_destructor;
   typedef __true_type    has_trivial_destructor;
 typedef __true_type    is_POD_type;
   typedef __true_type    is_POD_type;
 }
				
				;
}
				
				;

 #endif
				#endif
		 
		以下是construct 和 destroy的实现
 #ifndef MEM_TOOlS_H
#ifndef MEM_TOOlS_H
 #define MEM_TOOlS_H
#define MEM_TOOlS_H
 #include "type_traits.h"
#include "type_traits.h"
 using namespace std;
using namespace std;
 namespace SGI
namespace SGI


 {
{
 template<typename T1, typename T2>
    template<typename T1, typename T2>
 inline void construct(T1* p, const T2& value)
    inline void construct(T1* p, const T2& value)

 
     {
{
 new(p)T1(value);
        new(p)T1(value);
 }
    }
 
    
 template<typename T>
    template<typename T>
 inline void construct(T* p)
    inline void construct(T* p)

 
     {
{
 new(p)T();
        new(p)T();
 }
    }

 template<typename T>
    template<typename T>
 void destroy(T* p)
    void destroy(T* p)

 
     {
{
 p->~T();
        p->~T();
 }
    }

 template<typename ForwardIterator>
    template<typename ForwardIterator>
 inline void destroy_aux(ForwardIterator first, ForwardIterator last, __false_type)
    inline void destroy_aux(ForwardIterator first, ForwardIterator last, __false_type)

 
     {
{
 for (; first < last; ++first)
        for (; first < last; ++first)
 destroy(&*first);
            destroy(&*first);

 cout << "false type" << endl;
        cout << "false type" << endl;
 }
    }

 template<typename ForwardIterator>
    template<typename ForwardIterator>
 inline void destroy_aux(ForwardIterator first, ForwardIterator last, __true_type)
    inline void destroy_aux(ForwardIterator first, ForwardIterator last, __true_type)

 
     {
{
 cout << "true type" << endl;
        cout << "true type" << endl;
 }
    }

 template<typename ForwardIterator>
    template<typename ForwardIterator>
 inline void destroy(ForwardIterator first, ForwardIterator last)
    inline void destroy(ForwardIterator first, ForwardIterator last)

 
     {
{
 _destroy(first, last, value_type(*first));
        _destroy(first, last, value_type(*first));
 }
    }

 template<typename ForwardIterator, typename T>
    template<typename ForwardIterator, typename T>
 inline void _destroy(ForwardIterator first, ForwardIterator last, T*)
    inline void _destroy(ForwardIterator first, ForwardIterator last, T*)

 
     {
{
 typedef __type_traits<T>::has_trivial_destructor trivial_destructor;
        typedef __type_traits<T>::has_trivial_destructor trivial_destructor;
 destroy_aux(first, last, trivial_destructor());
        destroy_aux(first, last, trivial_destructor());
 }
    }

 inline void destroy(char*, char*)
    inline void destroy(char*, char*) 

 
     {
{
 cout << "char* type" << endl;
        cout << "char* type" << endl;
 }
    }
 inline void destroy(wchar_t*, wchar_t*)
    inline void destroy(wchar_t*, wchar_t*) 

 
     {
{
 cout << "wchar_t* type" << endl;
        cout << "wchar_t* type" << endl;
 }
    }    

 }
}

 #endif
#endif在main中对construct,destroy时行测试
 // mem_tools.cpp : 定义控制台应用程序的入口点。
// mem_tools.cpp : 定义控制台应用程序的入口点。
 //
//

 /**//*
/**//*
 *    模仿实现SGI STL中的内存工具
 *    模仿实现SGI STL中的内存工具
 *  szwolf @ szu
 *  szwolf @ szu
 *  2006.08.07
 *  2006.08.07
 */
 */
 #include "stdafx.h"
#include "stdafx.h"
 #include "sgi_allocator.h"
#include "sgi_allocator.h"
 #include <iostream>
#include <iostream>
 #include <vector>
#include <vector>
 #include <algorithm>
#include <algorithm>
 #include "mem_tools.h"
#include "mem_tools.h"

 class mem_test
class mem_test


 {
{
 public:
public:
 mem_test(const char* msg)
    mem_test(const char* msg)

 
     {
{
 cout << msg << endl;
        cout << msg << endl;
 }
    }

 ~mem_test()
    ~mem_test()

 
     {
{
 cout << "dead~~" << endl;
        cout << "dead~~" << endl;
 }
    }
 };
};

 int _tmain(int argc, _TCHAR* argv[])
int _tmain(int argc, _TCHAR* argv[])


 {
{
 //    很郁闷为什么下面的代码是错的?
    //    很郁闷为什么下面的代码是错的?
 //    typedef simple_alloc<mem_test, SGI::alloc> data_allcator;
    //    typedef simple_alloc<mem_test, SGI::alloc> data_allcator;
 //    mem_test* t = data_allocator::allocate();
    //    mem_test* t = data_allocator::allocate();

 SGI::simple_alloc<mem_test, SGI::alloc> data_allocator;
    SGI::simple_alloc<mem_test, SGI::alloc> data_allocator;
 
    
 mem_test* t = data_allocator.allocate();
    mem_test* t = data_allocator.allocate();

 SGI::construct(t, "come to live!");
    SGI::construct(t, "come to live!");
 SGI::destroy(&*t);
    SGI::destroy(&*t);

 SGI::simple_alloc<char, SGI::alloc> char_alloc;
    SGI::simple_alloc<char, SGI::alloc> char_alloc;
 char *p = char_alloc.allocate(133);
    char *p = char_alloc.allocate(133);
 strcpy(p, "hellow!");
    strcpy(p, "hellow!");
 SGI::destroy(p,p+8);
    SGI::destroy(p,p+8);
 char_alloc.deallocate(p, 133);
    char_alloc.deallocate(p, 133);

 system("pause");
    system("pause");
 return 0;
    return 0;
 }
}实中用到的simple_alloc及sgi_allocator.h是上一篇随笔里的东西。。。