Added support for policy based explicit/implicit constructor
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@131 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
36a53ca896
commit
30b3c736af
1 changed files with 86 additions and 61 deletions
|
@ -779,10 +779,27 @@ namespace Loki
|
||||||
SmartPtr, const SmartPtr>::Result
|
SmartPtr, const SmartPtr>::Result
|
||||||
CopyArg;
|
CopyArg;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct NeverMatched;
|
||||||
|
|
||||||
|
#ifdef LOKI_SMARTPTR_CONVERSION_CONSTRUCTOR_POLICY
|
||||||
|
typedef typename Select< CP::allow, const StoredType&, NeverMatched>::Result ImplicitArg;
|
||||||
|
typedef typename Select<!CP::allow, const StoredType&, NeverMatched>::Result ExplicitArg;
|
||||||
|
#else
|
||||||
|
typedef const StoredType& ImplicitArg;
|
||||||
|
typedef typename Select<false, const StoredType&, NeverMatched>::Result ExplicitArg;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
SmartPtr()
|
SmartPtr()
|
||||||
{ KP::OnDefault(GetImpl(*this)); }
|
{ KP::OnDefault(GetImpl(*this)); }
|
||||||
|
|
||||||
SmartPtr(const StoredType& p) : SP(p)
|
explicit
|
||||||
|
SmartPtr(ExplicitArg p) : SP(p)
|
||||||
|
{ KP::OnInit(GetImpl(*this)); }
|
||||||
|
|
||||||
|
SmartPtr(ImplicitArg p) : SP(p)
|
||||||
{ KP::OnInit(GetImpl(*this)); }
|
{ KP::OnInit(GetImpl(*this)); }
|
||||||
|
|
||||||
SmartPtr(CopyArg& rhs)
|
SmartPtr(CopyArg& rhs)
|
||||||
|
@ -1231,6 +1248,14 @@ namespace std
|
||||||
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
|
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
|
||||||
// December 09, 2001: Included <cassert>
|
// December 09, 2001: Included <cassert>
|
||||||
// February 2, 2003: fixed dependent names - credit due to Rani Sharoni
|
// February 2, 2003: fixed dependent names - credit due to Rani Sharoni
|
||||||
|
// August 21, 2003: Added support for policy based explicit/implicit constructor.
|
||||||
|
// The new code will be effective if a macro named
|
||||||
|
// *** LOKI_SMARTPTR_CONVERSION_CONSTRUCTOR_POLICY ***
|
||||||
|
// is defined (due to backward computability concerns).
|
||||||
|
// In case that the macro is defined and the conversion policy allow flag is off
|
||||||
|
// (e.g. DisallowConversion) then the conversion from the "pointer" to the
|
||||||
|
// SmartPtr must be explicit.
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#endif // SMARTPTR_INC_
|
#endif // SMARTPTR_INC_
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue