zoukankan
html css js c++ java
GameStd
/***************************************************************************************************** * File name: GameStd.h * Create time: 2015/03/02 * Module: View * Author: zengqh * Blog: http://blog.csdn.net/aimyton * --------------------------------------------------------------------------------------------------- * Memo: * *****************************************************************************************************/ #ifndef GameStd_h__ #define GameStd_h__ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <iostream> #include <vector> #include <map> #include <list> #include <deque> #include <queue> #include <set> #include <stack> #include <string> #include <algorithm> #include <functional> /***************************************************************************************************** * Macro and Struct definition *****************************************************************************************************/ /* assert thing */ #define MY_ASSERT(exp) { if (!(exp)) {__asm int 3} } #ifdef _DEBUG #define game_assert MY_ASSERT #else #define game_assert #endif /* safe delete */ #define safe_delete(p) { if((p) != NULL) { delete (p); (p) = NULL; } } #define safe_delete_array(p) { if((p) != NULL) { delete [] (p); (p) = NULL; } } #define safe_release(p) { if((p) != NULL) { (p)->Release(); } } /***************************************************************************************************** * Global variables *****************************************************************************************************/ /***************************************************************************************************** * Global function declare *****************************************************************************************************/ /***************************************************************************************************** * Global function definition *****************************************************************************************************/ inline void* impl_malloc(unsigned int size) { return ::malloc(size); } inline void impl_free(void* ptr) { return ::free(ptr); } /***************************************************************************************************** * Class declare ******************************************************************************************************/ class GameObject { public: virtual ~GameObject() {} void* operator new(unsigned int size) { return impl_malloc(size); } void* operator new(unsigned int size, void* ptr) { size; return ptr; } void operator delete(void* ptr) { impl_free(ptr); } void* operator new[](unsigned int size) { return impl_malloc(size); } void operator delete[](void* ptr) { impl_free(ptr); } void* malloc(unsigned int size) { return impl_malloc(size); } void free(void* ptr) { impl_free(ptr); } }; namespace std { template<class _T> class game_allocator { public: typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef _T* pointer; typedef const _T* const_pointer; typedef _T& reference; typedef const _T& const_reference; typedef _T value_type; template<class _Other> struct rebind { typedef game_allocator<_Other> other; }; game_allocator() { } game_allocator(const game_allocator<_T>&) { } template<class _Y> game_allocator(const game_allocator<_Y>&) { } pointer address(reference _val) const { return (&_val); } const_pointer address(const_reference _val) const { return (&_val); } pointer allocate(size_type _count) { return ((pointer)impl_malloc(_count * sizeof(_T))); } pointer allocate(size_type _count, const void* p) { return allocate(_count); } void deallocate(pointer _ptr, size_type) { impl_free(_ptr); } void construct(pointer _ptr, const _T& _val) { new ((void*)_ptr) _T(_val) } void destroy(pointer _ptr) { _ptr->~_T(); } size_type max_size() const { size_type _n = (size_type)(-1) / sizeof(_T); return (0 < _n ? _n : 1); } bool operator==(const game_allocator<_T>&) const { return true; } }; }; template <class T> class game_vector : public std::vector<T, std::game_allocator<T> > {}; template <class T> class game_list : public std::list<T, std::game_allocator<T> > {}; template <class T> class game_deque : public std::deque<T, std::game_allocator<T> > {}; template <class K, class C = std::less<K> > class game_set : public std::set<K, C, std::game_allocator<K> > {}; template <class K, class T, class C = std::less<K> > class game_map : public std::map<K, T, C, std::game_allocator<T> > {}; template <class T> class game_stack : public std::stack<T, game_deque<T> > {}; template <class T> class game_queue : public std::queue<T, game_deque<T> > {}; template <class T> class game_priority_queue : public std::priority_queue<T, game_vector<T> > {}; typedef std::basic_string<char, std::char_traits<char>, std::game_allocator<char> > game_string; /***************************************************************************************************** * Class definition *****************************************************************************************************/ #endif /* GameStd_h__ */ /***********************************End of File*******************************************************/
查看全文
相关阅读:
替换gitlab自带的Nginx,并修改仓库存储路径
linux 内网scp 无密码传输
centos7 安装docker及Hyperf
VMware 安装centos 7 及自动挂载共享文件夹
基于 Thrift + Laravel RPC 调用实现
PHP计算两个经纬度地点之间的距离
sql server 2008安装过程中服务器配置出错
SQL Server2008如何设置开启远程连接
向上下左右不间断无缝滚动图片的效果(兼容火狐和IE)
彻底解决Google浏览器CSS居中问题
原文地址:https://www.cnblogs.com/zengqh/p/2477400.html
最新文章
可滚动UIStackView 竖向居中 / 横向右对齐
横向滚动的UIStackView
Objective-C基础教程 笔记
C# 今天时间 今天结束时间
C# List<string> to string
C# deep copy List
磁盘映射挂载
git pull时解决分支分叉(branch diverged)问题
git基本命令之删除撤销操作
git cherry-pick基本使用
热门文章
LeetCode关于数组中求和的题型
HTTPS工作原理和TCP握手机制
数据库索引的实现原理
输入N组父子对,求父子对所组成的二叉树的高度----17年某公司的笔试题
给定一个十进制数,将其转化为N进制数-----17年滴滴笔试题
求数组中的逆序对的数量----剑指offer36题
php 使用GuzzleHttp请求接口,传输文件buffer
mysql 事务隔离级别之可能出现的问题:同一事务中无法查询已插入但未提交的数据
设置PHP最大连接数及php-fpm 高并发 参数调整
linux 重启PHP-FPM
Copyright © 2011-2022 走看看