📄 wyr_ret.h
字号:
/* Copyright is licensed under GNU LGPL. by I.J.Wang 2003 Note: If symbol WYLIB_CONFIG_NORSLI is defined, no SLI in WyRet This file is part of wyret.h and is included there. Definition code is in wyret.cpp*/#ifndef WYR_RET_H__#define WYR_RET_H__#define WYR_RET_VERSION 31/*[Thread-Safe] Note: WyRet is-a WyReply added with only SLI. So publicly derived. (test code indicates minor runtime overhead by SLI, the major overhead is by returnning class. 'return int' is 8-times faster than 'return(Ok)', 12-times faster than 'WY_RETURN(Ok)'. Note: sizeof(WyRet) is limited to the largest size of std::exception family to ensure safty. WyRet contains no virtual member because of the above concern. Note: All member functions do not throw*/class WyRet : public WyReply { public: inline WyRet() WY__NOTHROW__ : WyReply()#ifndef WYLIB_CONFIG_NORSLI,_slp(NULL) #endif {}; inline WyRet(const WyRet& r) WY__NOTHROW__ : WyReply(r)#ifndef WYLIB_CONFIG_NORSLI,_slp(r._slp) #endif {}; inline WyRet(const WyReply& em) WY__NOTHROW__ : WyReply(em)#ifndef WYLIB_CONFIG_NORSLI, _slp(NULL)#endif {}; inline WyRet(WyRet& r, Wy::ByMove_t) WY__NOTHROW__ : WyReply(r,Wy::ByMove)#ifndef WYLIB_CONFIG_NORSLI,_slp(r._slp) #endif {}; explicit inline WyRet(Wy__ErrNoType en) WY__NOTHROW__ : WyReply(en)#ifndef WYLIB_CONFIG_NORSLI, _slp(NULL)#endif {}; // [Derived] // Note: SLI is not the class's responsibility //inline bool is_default(void) const WY__NOTHROW__ inline void reset(void) WY__NOTHROW__ { WyReply::reset();#ifndef WYLIB_CONFIG_NORSLI _slp=NULL;#endif }; inline void reset(const WyReply& em) WY__NOTHROW__ { WyReply::reset(em);#ifndef WYLIB_CONFIG_NORSLI _slp=NULL; #endif }; inline void reset(const WyRet& r) WY__NOTHROW__ { WyReply::reset(r);#ifndef WYLIB_CONFIG_NORSLI _slp=r._slp; #endif }; inline const WyRet& operator =(const WyReply& em) WY__NOTHROW__ { WyReply::operator =(em);#ifndef WYLIB_CONFIG_NORSLI _slp=NULL; #endif return(*this); }; inline const WyRet& operator =(const WyRet& r) WY__NOTHROW__ { WyReply::operator =(r);#ifndef WYLIB_CONFIG_NORSLI _slp=r._slp; #endif return(*this); }; // [Derived] // Wy_RepInfo* operator->() const WY__NOTHROW__ inline bool operator ==(const WyReply& em) const WY__NOTHROW__ { return WyReply::operator==(em); }; inline bool operator !=(const WyReply& em) const WY__NOTHROW__ { return WyReply::operator!=(em); }; inline bool operator ==(const WyRet& r) const WY__NOTHROW__ { return WyReply::operator==(r); }; inline bool operator !=(const WyRet& r) const WY__NOTHROW__ { return WyReply::operator!=(r); }; // Note: SLI is not the class's property for equality //#ifndef WYLIB_CONFIG_NORSLI inline const Wy_SrcLoc* sli_ptr(void) const WY__NOTHROW__ { return _slp; };#endif // Note: SLI is not the class's property for equality // Note: The source location object should exist constantly // throughout the program life time. //#ifndef WYLIB_CONFIG_NORSLI inline const WyRet& set_sli(const Wy_SrcLoc* s) WY__NOTHROW__ { _slp=s; return *this; };#endif protected:#ifndef WYLIB_CONFIG_NORSLI inline WyRet(const WyRet& r, const Wy_SrcLoc* s) WY__NOTHROW__ : WyReply(r), _slp(s) {}; inline WyRet(const WyReply& em, const Wy_SrcLoc* s) WY__NOTHROW__ : WyReply(em), _slp(s) {}; #endif private:#ifndef WYLIB_CONFIG_NORSLI const Wy_SrcLoc *_slp;#endif // Hidden // // The purpose is to avoid ambiguity, and for easy maintenance // void reset(int); const WyRet& operator =(int); bool operator ==(int) const;};#endif // WYR_RET_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -