From 95fadc526007e0d25c5083e8d066e36bb5dea9f9 Mon Sep 17 00:00:00 2001 From: syntheticpp Date: Mon, 16 Jan 2006 00:05:02 +0000 Subject: [PATCH] msvc work around git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@476 7ec92016-0320-0410-acc4-a06ded1c099a --- include/loki/Pimpl.h | 8 +---- include/loki/PimplDef.h | 25 +++++++++++++- test/Pimpl/main.cpp | 1 + test/Pimpl/type2.h | 75 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 8 deletions(-) create mode 100755 test/Pimpl/type2.h diff --git a/include/loki/Pimpl.h b/include/loki/Pimpl.h index e8d34c5..5a29627 100755 --- a/include/loki/Pimpl.h +++ b/include/loki/Pimpl.h @@ -41,13 +41,7 @@ namespace Loki template struct AutoDeletePimpl { - static void Destroy(T ptr) - { - typedef char T_must_be_defined[ - sizeof(typename TypeTraits::PointeeType) ? 1 : -1 ]; - delete ptr; - ptr = 0; - } + static void Destroy(T ptr); }; template diff --git a/include/loki/PimplDef.h b/include/loki/PimplDef.h index d3d0eac..6f42e80 100755 --- a/include/loki/PimplDef.h +++ b/include/loki/PimplDef.h @@ -16,6 +16,29 @@ namespace Loki { + template + void AutoDeletePimpl::Destroy(T ptr) + { +#ifndef _MSC_VER // msvc bug + + typedef char T_must_be_defined[ + sizeof(typename TypeTraits::PointeeType) ? 1 : -1 ]; + delete ptr; + ptr = 0; + +#else + +#pragma warning(push) +#pragma warning(disable: 4150) + + delete ptr; + ptr = 0; + +#pragma warning(pop) +#endif + } + + template < class Impl, @@ -24,7 +47,7 @@ namespace Loki > inline PimplLife::PimplLife() //: ptr(Ptr()) this owerwrites the pointer to PtrImpl - {} // when using DeclaredRimpl!! + {} // when using DeclaredRimpl!! template < diff --git a/test/Pimpl/main.cpp b/test/Pimpl/main.cpp index 78f7eb8..04f15b7 100755 --- a/test/Pimpl/main.cpp +++ b/test/Pimpl/main.cpp @@ -21,6 +21,7 @@ #define LOKI_INHERITED_RIMPL_NAME d #include "type.h" +#include "type2.h" #include diff --git a/test/Pimpl/type2.h b/test/Pimpl/type2.h new file mode 100755 index 0000000..05e4355 --- /dev/null +++ b/test/Pimpl/type2.h @@ -0,0 +1,75 @@ +//////////////////////////////////////////////////////////////////////////////// +// The Loki Library +// Copyright (c) 2006 Peter Kümmel +// Permission to use, copy, modify, distribute and sell this software for any +// purpose is hereby granted without fee, provided that the above copyright +// notice appear in all copies and that both that copyright notice and this +// permission notice appear in supporting documentation. +// The author makes no representations about the +// suitability of this software for any purpose. It is provided "as is" +// without express or implied warranty. +//////////////////////////////////////////////////////////////////////////////// + +// $Header: + + +#include + +using Loki::Pimpl; +using Loki::Rimpl; + + +///////////////////////////////////////// +// class A2 declaration +///////////////////////////////////////// + +class A2 +{ +public: + A2(); + void foo(); + +private: + Pimpl::Type d; +}; + + +///////////////////////////////////////// +// class B2 declaration +///////////////////////////////////////// + +class B2 : private Pimpl::Owner +{ +public: + B2(); + void foo(); +}; + + +///////////////////////////////////////// +// class C2 declaration +///////////////////////////////////////// + +class C2 +{ +public: + C2(); + void foo(); + +private: + Rimpl::Life rlife; + Rimpl::Type& d; +}; + + +///////////////////////////////////////// +// class D2 declaration +///////////////////////////////////////// + +class D2 : private Rimpl::Owner +{ +public: + D2(); + void foo(); +}; +