基础类:Basic.h

重在学习思想,难得的开源库

简单介绍,猜测意图

一.基本类型

1.NotCopyable

意图:阻止继承子类被拷贝

.h

class NotCopyable
{
private:
    NotCopyable(const NotCopyable&);
    NotCopyable& operator=(const NotCopyable&);
public:
    NotCopyable();
};

.cpp

NotCopyable::NotCopyable()
{
}

NotCopyable::NotCopyable(const NotCopyable&)
{
}

NotCopyable& NotCopyable::operator=(const NotCopyable&)
{
    return *this;
}

2.Error

意图:用于抛错

class Error
{
private:
    wchar_t*            description;
public:
    Error(wchar_t* _description);

    wchar_t*            Description()const;
};

3.Object

意图:学习.net和java等语言,提供一个空的基类

class Object
{
public:
    virtual ~Object();
};

4.ObjectBox

意图:提供一份对象的拷贝

template<typename T>
class ObjectBox : public Object
{
private:
    T                    object;
public:
    ObjectBox(const T& _object)
    {
        object=_object;
    }

    const T& Unbox()
    {
        return object;
    }
};

5.BinaryRetriver

意图:提供一个联合体,minSize为默认最小大小,t一般不会超过其大小

template<typename T, size_t minSize>
union BinaryRetriver
{
    T t;
    char binary[sizeof(T)>minSize?sizeof(T):minSize];
};

demo示例:

const int BinarySize = sizeof(void*)*8;
BinaryRetriver<int*, BinarySize> retriver;
memset(retriver.binary, 0, BinarySize);

6.KeyType

7.POD

8.DateTime

意图:提供时间类的封装

9.Interface

class Interface : private NotCopyable
{
public:
    virtual ~Interface();
};

意图:提供接口基类

相关文章:

  • 2022-01-12
  • 2021-04-26
  • 2021-10-03
  • 2021-09-28
  • 2022-12-23
  • 2021-07-13
  • 2021-11-07
  • 2021-06-11
猜你喜欢
  • 2021-06-22
  • 2021-08-25
  • 2022-01-30
  • 2021-11-04
  • 2021-06-17
  • 2022-12-23
  • 2021-12-13
相关资源
相似解决方案