allocator.h
来自「有关MYSQL的开源码」· C头文件 代码 · 共 48 行
H
48 行
#ifndef MYSQLCPPAPI_ALLOCATOR_H#define MYSQLCPPAPI_ALLOCATOR_H#include "mysqlcppapi/exceptions/ex_base.h"namespace mysqlcppapi{//Derive new Allocators to use e.g. ct_cmd_alloc and ct_cmd_drop instead of new and delete.template<typename T_cobj>class Allocator{public: typedef T_cobj cvalue_type; typedef T_cobj* cpointer; //An actual derived Allocator should implement these methods: //static cpointer allocate(); // //static void deallocate(cpointer pInstance);};//Allocator that implements allocate() and deallocate() with simple C++ new and delete.template<typename T_cobj>class Allocator_NewDelete : public Allocator<T_cobj>{public: typedef typename Allocator<T_cobj>::cpointer cpointer; static cpointer allocate() { return new T_cobj(); } static void deallocate(cpointer pInstance) { delete pInstance; }};} //namespace#endif //MYSQLCPPAPI_ALLOCATOR_H
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?