Skip to content

Replace implicit lamda captures for C++20#518

Merged
RytoEX merged 1 commit into
obsproject:masterfrom
RytoEX:update-to-cpp-20
May 1, 2026
Merged

Replace implicit lamda captures for C++20#518
RytoEX merged 1 commit into
obsproject:masterfrom
RytoEX:update-to-cpp-20

Conversation

@RytoEX
Copy link
Copy Markdown
Member

@RytoEX RytoEX commented Apr 10, 2026

Description

Implicit capture of 'this' with a capture default of '=' is deprecated in C++20. While the standard recommends replacing '=' with '=, this', that syntax is not C++17 compatible, and we will likely need some transition period where obs-studio and its modules are still built using C++17.

Motivation and Context

Want obs-studio and its submodules to build with C++20 some day.

How Has This Been Tested?

Compiled and tested on Windows 11.

Types of changes

  • Code cleanup (non-breaking change which makes code smaller or more readable)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Implicit capture of 'this' with a capture default of '=' is deprecated
in C++20. While the standard recommends replacing '=' with '=, this',
that syntax is not C++17 compatible, and we will likely need some
transition period where obs-studio and its modules are still built
using C++17.
@RytoEX RytoEX self-assigned this Apr 10, 2026
Copy link
Copy Markdown
Member

@PatTheMav PatTheMav left a comment

Choose a reason for hiding this comment

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

My initial reaction is that "explicit capture lists" are actually great (explicit is better than implicit), though too long lists might become harder to parse.

I think in that case the same applies as with function signatures: If you design it in such a way that it requires ~10 arguments, chances are that those arguments might be better placed in a structure and that structure being passed along as the argument (or context data).

@RytoEX RytoEX merged commit 19b1c96 into obsproject:master May 1, 2026
1 check passed
@RytoEX RytoEX deleted the update-to-cpp-20 branch May 1, 2026 15:15
@RytoEX RytoEX mentioned this pull request May 4, 2026
6 tasks
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.

2 participants