![]() |
Templates -- Meow
1.1.4
A C++ template which is unable and also not allowed to compile to obj-file first.
|
A little class use for packing the data part of another class. With this technique, it can achieve Copy-On-Write(COR) mechanism at background and have a reference mechanism which much more flexible then the one C++ has. More...
#include "Self.h"
Public Types | |
enum | DuplicateType { COPY_FROM, REFERENCE_FROM } |
Kind of ways of duplicating. More... | |
Public Member Functions | |
Self () | |
constructor with a real entity More... | |
Self (Data const &d) | |
connstructor with a real entity with it using its copy constructor More... | |
Self (Self const &b, DuplicateType d) | |
constructor with given another Self More... | |
Self (Self const &b) | |
Disallow copy constructor. More... | |
~Self () | |
destructor More... | |
Data const * | operator-> () const |
Return the constant pointer to the data. More... | |
Data * | operator-> () |
Return the non-constant pointer to the data (COR's clone might occure here. More... | |
Self & | operator() () const |
Return the non-constant reference of *this . More... | |
Self const & | copyFrom (Self const &s) |
Copy the gived Self to myself. More... | |
Self const & | referenceFrom (Self const &s) |
Reference myself from given Self object. More... | |
Self const & | duplicateFrom (Self const &s, DuplicateType t) |
call copyFrom() or referenceFrom() depend on your instruction More... | |
bool | same (Self const &s) const |
Compare tht if the gived Self object is reference from the same object of me. More... | |
bool | equal (Self const &s) const |
Compare that the data are the same. More... | |
bool | referenceLess (Self const &s) const |
Order compare by reference pointer. More... | |
void | operator= (Self const &a) |
Disallow default 'operator=' . More... | |
A little class use for packing the data part of another class. With this technique, it can achieve Copy-On-Write(COR) mechanism at background and have a reference mechanism which much more flexible then the one C++ has.
Sample code:
Note that 'referenceFrom()' will cause the two object become the same one, Which means that if you do something like 'a.referenceFrom(b)
; a.copyFrom(c)
; ', the result is that the value of a
,b,c will all the same one.
operator=
and copy constructor in order to prevent upexplicit default behavior, so if you want to have one of them (or both), you must implement yourself enum meow::Self::DuplicateType |
|
inline |
|
inline |
|
inline |
meow::Self< Data >::Self | ( | Self< Data > const & | b | ) |
Disallow copy constructor.
|
inline |
|
inline |
|
inline |
call copyFrom()
or referenceFrom()
depend on your instruction
[in] | s | gived Self object |
[in] | t | instruction |
|
inline |
|
inline |
|
inline |
|
inline |
void meow::Self< Data >::operator= | ( | Self< Data > const & | a | ) |
Disallow default 'operator='
.
|
inline |
|
inline |
|
inline |