Wiki

Case Status
Log In

Wiki

 
Whole Tomato Software - Home
  • RSS Feed

Convert Between Pointer and Instance

Refactor with "Convert Between Pointer and Instance" to change object pointers to object references, and vice versa. The refactoring converts a declaration, swaps "." and "->" in references, and adjusts "*" and "&" as necessary.

Access

Access "Convert Between Pointer and Instance" via the context menu of the text editor (Right-click or Shift+F10), or via the Quick Actions and Refactoring menu (Shift+Alt+Q). The command is available only when the text caret is on the declaration of a local variable.

Convert Pointer to Instance

When converting a pointer to an instance, select the references to convert in the dialog that opens. References to "delete", if any, will be removed.

Convert Instance to Pointer

When converting an instance to a pointer, select the pointer type in the dialog that opens. If converting to a raw pointer, you must manage the lifecycle of the pointer, e.g. add a "delete" when the variable is no longer needed.

If you convert to a smart pointer, the converted declaration will use std::make_unique or std::make_shared.

By default, the converted variable will be declared using "auto". Uncheck use-auto in the dialog to convert using an explicit type.

To convert an instance to a pointer using a template, select "custom" and enter a name of a function template. Optionally, enter a comma and explicit type.

If you omit a type, the converted variable will be declared using "auto".

Unsupported Scenario

A message appears if "Convert Between Pointer and Instance" cannot refactor the selected variable.