msvc work around
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@476 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
2287a53487
commit
95fadc5260
4 changed files with 101 additions and 8 deletions
|
@ -41,13 +41,7 @@ namespace Loki
|
|||
template<class T>
|
||||
struct AutoDeletePimpl
|
||||
{
|
||||
static void Destroy(T ptr)
|
||||
{
|
||||
typedef char T_must_be_defined[
|
||||
sizeof(typename TypeTraits<T>::PointeeType) ? 1 : -1 ];
|
||||
delete ptr;
|
||||
ptr = 0;
|
||||
}
|
||||
static void Destroy(T ptr);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
|
|
@ -16,6 +16,29 @@
|
|||
|
||||
namespace Loki
|
||||
{
|
||||
template<class T>
|
||||
void AutoDeletePimpl<T>::Destroy(T ptr)
|
||||
{
|
||||
#ifndef _MSC_VER // msvc bug
|
||||
|
||||
typedef char T_must_be_defined[
|
||||
sizeof(typename TypeTraits<T>::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,
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define LOKI_INHERITED_RIMPL_NAME d
|
||||
|
||||
#include "type.h"
|
||||
#include "type2.h"
|
||||
|
||||
#include <loki/PimplDef.h>
|
||||
|
||||
|
|
75
test/Pimpl/type2.h
Executable file
75
test/Pimpl/type2.h
Executable file
|
@ -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 <loki/Pimpl.h>
|
||||
|
||||
using Loki::Pimpl;
|
||||
using Loki::Rimpl;
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
// class A2 declaration
|
||||
/////////////////////////////////////////
|
||||
|
||||
class A2
|
||||
{
|
||||
public:
|
||||
A2();
|
||||
void foo();
|
||||
|
||||
private:
|
||||
Pimpl<A>::Type d;
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
// class B2 declaration
|
||||
/////////////////////////////////////////
|
||||
|
||||
class B2 : private Pimpl<B2>::Owner
|
||||
{
|
||||
public:
|
||||
B2();
|
||||
void foo();
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
// class C2 declaration
|
||||
/////////////////////////////////////////
|
||||
|
||||
class C2
|
||||
{
|
||||
public:
|
||||
C2();
|
||||
void foo();
|
||||
|
||||
private:
|
||||
Rimpl<C2>::Life rlife;
|
||||
Rimpl<C2>::Type& d;
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
// class D2 declaration
|
||||
/////////////////////////////////////////
|
||||
|
||||
class D2 : private Rimpl<D2>::Owner
|
||||
{
|
||||
public:
|
||||
D2();
|
||||
void foo();
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue