Skip to content

fix universal: fix initialization of default values in FindOrDefault#1187

Open
ddvamp wants to merge 2 commits intouserver-framework:developfrom
ddvamp:userver-patch
Open

fix universal: fix initialization of default values in FindOrDefault#1187
ddvamp wants to merge 2 commits intouserver-framework:developfrom
ddvamp:userver-patch

Conversation

@ddvamp
Copy link
Copy Markdown
Contributor

@ddvamp ddvamp commented Apr 22, 2026

Fixes #1186

const auto* ptr = USERVER_NAMESPACE::utils::FindOrNullptr(container, key);
return (ptr ? *ptr : decltype(*ptr){std::forward<Default>(def)});
using R = std::remove_cvref_t<decltype(*ptr)>;
return (ptr ? *ptr : R(std::forward<Default>(def)));
Copy link
Copy Markdown
Member

@apolukhin apolukhin Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, add tests for the functionality

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly should they test?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно создать тест, который показывает проблему, исправляемую в PR

Те тесты что сейчас добавлены, кажется что проблему не подсвечивают

@ddvamp ddvamp changed the title fix utils: fix initialization of default values in FindOrDefault fix universal: fix initialization of default values in FindOrDefault Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect initialization of default-values in FindOrDefault

2 participants