Use in-class initializers for constant member values (C.48)#20449
Merged
Conversation
Move constant member initializers out of constructor initializer lists and into in-class member initializers, per C++ Core Guidelines C.48 and the coding standards discussion in microsoft#962. This first batch covers six classes whose constructors initialized members with only constant values: - ConsoleObjectHeader (server): 5 counter members; ctor now defaulted - ConsoleHandleData (server): _pvClientPointer, _pClientInput - ConsoleProcessHandle (server): pInputHandle, pOutputHandle, fRootProcess, _ulTerminateCount - OutputCellRect (buffer/out): _rows, _cols; default ctor defaulted - Icon (interactivity/win32): 5 handle/state members - Window (interactivity/win32): 6 pointer/flag/dpi members Initialization values and ordering are unchanged; no behavioral difference. Validated with a full solution build (0 errors) and the Conhost unit tests covering these classes (ObjectTests, TextBuffer). Part of microsoft#962
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
Author
|
@microsoft-github-policy-service agree |
lhecker
approved these changes
Jul 20, 2026
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
DHowett
approved these changes
Jul 20, 2026
nsfxdyj
added a commit
to nsfxdyj/terminal
that referenced
this pull request
Jul 20, 2026
Second batch for microsoft#962, following the same approach as microsoft#20449. Moves 24 scalar constant member initializers for the Settings class out of the constructor initializer list and into in-class member initializers. Initializers that depend on file-local constexpr values (DEFAULT_NUMBER_OF_COMMANDS, DEFAULT_NUMBER_OF_BUFFERS), Windows macros composed in the .cpp (FOREGROUND_*, SW_SHOWNORMAL, BYTE_MAX, Cursor::CURSOR_SMALL_SIZE), or runtime state (ServiceLocator::LocateGlobals().uiOEMCP) intentionally remain in the constructor, since moving them to the header would break the build or is not a constant initializer. No behavioral change. Validated with an incremental solution build (0 errors).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #962. Moves constant member initializers out of constructor initializer lists and into in-class member initializers, per C++ Core Guidelines C.48.
This is a first, focused batch covering six classes whose constructors initialized members with only constant values:
ConsoleObjectHeader(server): 5 counter members; ctor now= defaultConsoleHandleData(server):_pvClientPointer,_pClientInputConsoleProcessHandle(server):pInputHandle,pOutputHandle,fRootProcess,_ulTerminateCountOutputCellRect(buffer/out):_rows,_cols; default ctor now= defaultIcon(interactivity/win32): 5 handle/state membersWindow(interactivity/win32): 6 pointer/flag/dpi membersValidation
OpenConsole.slnx, x64 Debug): 0 errorsConhost.Unit.Tests(ObjectTestscoversConsoleObjectHeader): passedTextBuffer.Unit.Tests: 13/13 passedInitialization values and ordering are unchanged; no behavioral difference. Follow-up PRs can cover the remaining candidates (e.g.
Settings,OutputCellIterator,GdiEngine) once this approach is agreed on.