• RSS Feed

Move Implementation to Source File

Refactoring with Move Implementation to Source File provides C/C++ users with an efficient mechanism for moving the implementation of a function or method from a header to a source file. This refactoring is often invoked after refactoring commands that place implementations in the header for inline execution, e.g. Encapsulate Field.

Move Method Implementations to Source File—the plural version of the command—moves all methods of a class in a single operation.

You can modify the format of implementations by editing the VA Snippet for Create Implementation.

Access

Place the caret on a function or method in a header, and select Move Implementation to Source File from a refactoring menu (Shift+Alt+Q).

Visual Assist moves the body to the appropriate source file. For methods, the implementation is placed within other implementations of the same class. Implementations of overloaded methods are moved near other overloads.

If necessary, a declaration is created in the header.

Location of Implementation

By default, Visual Assist places new implementations near those of neighboring declarations. Alternatively, Visual Assist can create implementations at the EOF of a source file. Specify your preference in the options dialog for Visual Assist.

Template Implementations

By default, Move Implementation to Source File will move inline template implementations out of the class definition, but keep them in the header. If the template implementation is outside the class definition, the implementation will be moved to a source file. If needed, you can refactor twice to move inline implementations outside the class definition, and then to the source file. You can turn off the custom behavior entirely by editing the registry.

Navigation

Use the Navigate commands of Visual Assist to jump between the header and source after Move Implementation to Source File. Immediately after the refactoring, Alt+Left returns you to the header. Alt+Right returns you to the implementation.

Registry Settings

Value Name Meaning
MoveTemplateImplToSourceInTwoSteps Adjust Move Implementation for templates