diff --git a/include/loki/Pimpl.h b/include/loki/Pimpl.h index 5eaf956..407129c 100755 --- a/include/loki/Pimpl.h +++ b/include/loki/Pimpl.h @@ -14,7 +14,6 @@ #include -// $Header$ #ifndef LOKI_INHERITED_PIMPL_NAME #define LOKI_INHERITED_PIMPL_NAME d @@ -33,6 +32,8 @@ namespace Loki struct Impl; + + ///////////////////// // creation policies ///////////////////// @@ -61,6 +62,31 @@ namespace Loki {} }; + ///////////////////// + // error handling + ///////////////////// + template + struct ExceptionOnPimplError + { + struct Exception : public std::exception + { + const char* what() const throw() { return "error in loki/Pimpl.h"; } + }; + + static void PimplError() + { + throw Exception(); + } + + }; + + template + struct IgnorPimplError + { + static void PimplError() + {} + + }; ///////////////////// // Helper class AutoPtrHolder to manage pimpl lifetime @@ -98,9 +124,10 @@ namespace Loki < class Impl, class Ptr, - template class Del + template class Del, + template class ErrorPolicy = ExceptionOnPimplError > - struct AutoPtrHolderChecked //: AutoPtrHolder + struct AutoPtrHolderChecked { static bool init_; @@ -118,9 +145,10 @@ namespace Loki template operator T&() { + // if this throws change the declaration order + // of the DeclaredRimpl construct if(!init_) - // if this throws change the declaration order - throw 1; + ErrorPolicy::PimplError(); Create(); return *ptr; } @@ -138,9 +166,10 @@ namespace Loki < class Impl, class Ptr, - template class Del + template class Del, + template class Err > - bool AutoPtrHolderChecked::init_ = false; + bool AutoPtrHolderChecked::init_ = false; template @@ -335,6 +364,9 @@ namespace Loki #endif // $Log$ +// Revision 1.7 2006/01/16 19:48:23 syntheticpp +// add error policy +// // Revision 1.6 2006/01/16 19:05:09 rich_sposato // Added cvs keywords. //