Description
This issue tracks a refactoring request to consistently use list initialization {} instead of the assignment operator = for variable declarations throughout the codebase to prevent narrowing conversions and improve consistency.
Background
List initialization (uniform initialization) introduced in C++11 provides several benefits:
- Prevents narrowing conversions
- More consistent syntax across different initialization contexts
- Clearer intent in variable declarations
Current State
Currently, the codebase uses a mix of assignment operator = and list initialization {} for variable declarations.
Example of current code:
auto const timestamp = get_timestamp(log_event);
Should be refactored to:
auto const timestamp{get_timestamp(log_event)};
Scope
This refactoring should be applied consistently across all C++ files in the codebase where variable declarations currently use the assignment operator and can benefit from list initialization.
References
Requested by: @junhaoliao
Description
This issue tracks a refactoring request to consistently use list initialization
{}instead of the assignment operator=for variable declarations throughout the codebase to prevent narrowing conversions and improve consistency.Background
List initialization (uniform initialization) introduced in C++11 provides several benefits:
Current State
Currently, the codebase uses a mix of assignment operator
=and list initialization{}for variable declarations.Example of current code:
Should be refactored to:
Scope
This refactoring should be applied consistently across all C++ files in the codebase where variable declarations currently use the assignment operator and can benefit from list initialization.
References
Requested by: @junhaoliao