我正在开发一个包含其他库的跨平台环境,特别是因为这有助于我理解C ++及其库/扩展,因为我对编程语言很陌生。
我正在为原始类型创建包装器,因此我可以为它们提供诸如eventSerialize(...),eventRepresentate(...)等功能(以及其他一些原因)。
为了节省时间,我想到为基元制作模板类包装器。
我有以下问题:
我希望有人能给我这些答案。
#ifndef swift_Int32
#define swift_Int32
#include <boost/cstdint.hpp>
namespace swift
{
template<class T> class Primitive : public Object
{
T data;
public:
Primitive();
Primitive(T&);
Primitive(Primitive<T>&);
Primitive<T>& operator = (const Primitive<T>&);
Primitive<T> operator * (const Primitive<T>& value);
Primitive<T> operator / (const Primitive<T>& value);
Primitive<T> operator + (const Primitive<T>& value);
Primitive<T> operator - (const Primitive<T>& value);
Primitive<T>& operator *= (const Primitive<T>& value);
Primitive<T>& operator /= (const Primitive<T>& value);
Primitive<T>& operator += (const Primitive<T>& value);
Primitive<T>& operator -= (const Primitive<T>& value);
bool operator == (const Primitive<T>&) const;
bool operator != (const Primitive<T>&) const;
bool operator < (const Primitive<T>&) const;
bool operator > (const Primitive<T>&) const;
bool operator <= (const Primitive<T>&) const;
bool operator >= (const Primitive<T>&) const;
};
typedef Primitive<bool> Bool;
typedef Bool Bit;
typedef Primitive<int8_t> Char;
typedef Primitive<uint8_t> Byte;
typedef Primitive<int16_t> Int16;
typedef Primitive<uint16_t> UInt16;
typedef Primitive<int32_t> Int32;
typedef Primitive<uint32_t> UInt32;
typedef Int16 Short;
typedef UInt16 UShort;
typedef Int32 Int;
typedef UInt32 UInt;
}
#endif //swift_Int32