1#pragma once 2#include <string> 3 4#include <string.h> // memset 5 6inline void memZero(void* p, size_t n) 7{ 8 memset(p, 0, n); 9} 10 11class noncopyable 12{ 13 protected: 14 noncopyable() {} 15 16 private: 17 noncopyable(const noncopyable&) = delete; 18 void operator=(const noncopyable&) = delete; 19}; 20 21struct copyable 22{ 23}; 24 25// For passing C-style string argument to a function. 26class StringArg : copyable 27{ 28 public: 29 StringArg(const char* str) 30 : str_(str) 31 { } 32 33 StringArg(const std::string& str) 34 : str_(str.c_str()) 35 { } 36 37 const char* c_str() const { return str_; } 38 39 private: 40 const char* str_; 41}; 42 43template<typename To, typename From> 44inline To implicit_cast(From f) 45{ 46 return f; 47} 48