From: <ag...@us...> - 2012-01-26 17:17:36
|
Revision: 2686 http://zoolib.svn.sourceforge.net/zoolib/?rev=2686&view=rev Author: agreen Date: 2012-01-26 17:17:25 +0000 (Thu, 26 Jan 2012) Log Message: ----------- Add NonConst and DynNonConst template functions. Move null into ZooLib namespace. Modified Paths: -------------- trunk/zoolib/source/cxx/zoolib/zconfigl.h Modified: trunk/zoolib/source/cxx/zoolib/zconfigl.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/zconfigl.h 2012-01-26 04:16:33 UTC (rev 2685) +++ trunk/zoolib/source/cxx/zoolib/zconfigl.h 2012-01-26 17:17:25 UTC (rev 2686) @@ -309,15 +309,48 @@ // empty value of some sort, but where we don't want to have to manually create the value each time. #ifdef __cplusplus - const class notnull_t {} notnull = {}; - const struct null_t - { - const notnull_t operator!() const { return notnull; } - } null = {}; + +namespace ZooLib { + +const class notnull_t {} notnull = {}; + +const struct null_t + { + const notnull_t operator!() const { return notnull; } + } null = {}; + +} // namespace ZooLib + #endif // ================================================================================================= +#ifdef __cplusplus + +namespace ZooLib { + +template <class T> +T* NonConst(const T* iT) + { return const_cast<T*>(iT); } + +template <class T> +T& NonConst(const T& iT) + { return const_cast<T&>(iT); } + +template <class P, class T> +P DynNonConst(const T* iT) + { return dynamic_cast<P>(NonConst(iT)); } + +template <class P, class T> +P DynNonConst(const T& iT) + { return dynamic_cast<P>(NonConst(iT)); } + +} // namespace ZooLib + +#endif + +// ================================================================================================= + #if __MACH__ #define ZMACINCLUDE2(a,b) <a/b> #if __MWERKS__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |