#ifndef _UNIX_LIB_MEMORY_HPP
#define _UNIX_LIB_MEMORY_HPP
/* author: piboye
* email : [email protected]
* date : 2006.06.2
*/
//头文件
#include<memory.h>
#include<assert.h>
namespace UNIX {
class Mem //提供内存操作,但不提供内存管理;
{
private:
void *i_start; //内存开始的位置
unsigned int i_length; //内存的长度,用unsigned 是为了保持与C接口的一致性;
public:
typedef enum {less=-1,great=1,equal=0} CmpT;//内存比较需要的结果 类型;
Mem(void *add,unsigned int len):i_start(add),i_length(len){assert(i_start&&i_length);} //add 不可以使用无效指针,但这是用户的责任;
Mem const & operator=(Mem const & rhs) // 封装了void* __cdecl memmove (void*, const void*, size_t); 如果内存可以重叠。
{
unsigned int const min=(i_length>rhs.i_length)?rhs.i_le