Skip to content

Initial c++17 cleanups#361

Merged
texus merged 6 commits into
texus:1.xfrom
jjuhl:initial-c++17-cleanups
May 11, 2026
Merged

Initial c++17 cleanups#361
texus merged 6 commits into
texus:1.xfrom
jjuhl:initial-c++17-cleanups

Conversation

@jjuhl
Copy link
Copy Markdown
Contributor

@jjuhl jjuhl commented May 11, 2026

Hi Texus

Here are a few initial C++17 cleanup patches for you.
There's much more in the pipeline but I don't have time to do more than this tonight, so I thought I'd just submit what I had done so far - more will come in future PR's.

jjuhl added 4 commits May 11, 2026 19:20
Since TGUI now requires C++17 we can just use std::clamp().
Since C++17 is now required, [[nodiscard]] is part of the language and
the TGUI_NODISCARD macro is no longer needed, so remove it.
C++17 is now the required minimum, so stop refering to C++14.
@jjuhl jjuhl force-pushed the initial-c++17-cleanups branch from 626e399 to 3f695a6 Compare May 11, 2026 17:20
@jjuhl
Copy link
Copy Markdown
Contributor Author

jjuhl commented May 11, 2026

Hmm, this apparently fails while building a C++20 module. I must admit that that is not something I have any experience with.. If you have an easy fix that would be great, otherwise I'll dig into it over the next couple of days.

@texus
Copy link
Copy Markdown
Owner

texus commented May 11, 2026

For the c++20 modules, all classes and global functions must be explicitly marked for export in src/TGUI.cppm. The tgui::clamp function is listed there, but it couldn't be found anymore because it was removed.
I had already forgotten that the TGUI.cppm file existed, it's likely some new things got added which I forgot to add there. At least when you remove something you get a compile error to tell you that you forgot (although an error in that file also means you are breaking the public API).

Even though TGUI code should no longer use TGUI_NODISCARD or tgui::clamp anywhere, custom widgets in user code might still be using them. So I'm keeping them available to keep backwards compatibility.

Since C++17 is now required, we can use the return value of vector::emplace_back
@texus texus merged commit 61fdf32 into texus:1.x May 11, 2026
14 checks passed
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