diff -r ebc84c812384 -r 46218c8b8afa Symbian3/PDK/Source/GUID-38C37BA5-B972-5C8B-B8DE-B2FECF2A3C3C.dita --- a/Symbian3/PDK/Source/GUID-38C37BA5-B972-5C8B-B8DE-B2FECF2A3C3C.dita Thu Mar 11 15:24:26 2010 +0000 +++ b/Symbian3/PDK/Source/GUID-38C37BA5-B972-5C8B-B8DE-B2FECF2A3C3C.dita Thu Mar 11 18:02:22 2010 +0000 @@ -1,22 +1,22 @@ - - - - - -Single Phase Constructor

Single phase constructor is to push a pointer to the clean-up stack, and then complete its construction. It uses the macro CONSTRUCTORS_MAY_LEAVE that is necessary to ensure whether the cleanup is correctly handled in the event that a constructor may leave beneath a call to new(ELeave).

Characteristics of single phase constructor

The following are the major characteristics of single phase constructor:

  • The implementation of NewL becomes much simpler

  • By using RAII classes in fields to manage owned resources, constructor exception-safety can be maintained

  • Cleanup stack technology

Example

The following code snippet implies the usage of single phase constructor using CONSTRUCTORS_MAY_LEAVE macro.

- class CManagedUserSinglePhase : public CBase - { - public: - CONSTRUCTORS_MAY_LEAVE - static CManagedUserSinglePhase* NewL(CTicker* aTicker) - { - return new(ELeave) CManagedUserSinglePhase(aTicker); - } - } + + + + + +Single Phase Constructor

Single phase constructor is to push a pointer to the clean-up stack, and then complete its construction. It uses the macro CONSTRUCTORS_MAY_LEAVE that is necessary to ensure whether the cleanup is correctly handled in the event that a constructor may leave beneath a call to new(ELeave).

Characteristics of single phase constructor

The following are the major characteristics of single phase constructor:

  • The implementation of NewL becomes much simpler

  • By using RAII classes in fields to manage owned resources, constructor exception-safety can be maintained

  • Cleanup stack technology

Example

The following code snippet implies the usage of single phase constructor using CONSTRUCTORS_MAY_LEAVE macro.

+ class CManagedUserSinglePhase : public CBase + { + public: + CONSTRUCTORS_MAY_LEAVE + static CManagedUserSinglePhase* NewL(CTicker* aTicker) + { + return new(ELeave) CManagedUserSinglePhase(aTicker); + } + }
See Also

EUser High Level Library Overview

EUser High Level Library Tutorials

\ No newline at end of file