Skip to content

C++20 support#4

Closed
white238 wants to merge 6 commits into
mainfrom
task/white238/cpp20
Closed

C++20 support#4
white238 wants to merge 6 commits into
mainfrom
task/white238/cpp20

Conversation

@white238

Copy link
Copy Markdown
Member

Fixes two compiler errors due to C++20 being more strict than C++17

Incomplete types are not allowed in std::any:

[ 28%] Building CXX object src/gretl/CMakeFiles/gretl.dir/data_store.cpp.o
In file included from /usr/WS2/white238/gretl/repo/src/gretl/data_store.cpp:7:
In file included from /opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/any:39:
/opt/rh/gcc-toolset-13/root/usr/lib/gcc/x86_64-redhat-linux/13/../../../../include/c++/13/type_traits:979:21: error: static assertion failed due to requirement 'std::__is_complete_or_unbounded(std::__type_identity<gretl::UpstreamStates>{})': template argument must be a complete class or an unbounded array
  979 |       static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Implicit this is not allowed in lambdas

/usr/WS2/white238/gretl/repo/src/gretl/data_store.cpp:229:54: error: implicit capture of 'this' with a capture default of '=' is deprecated [-Werror,-Wdeprecated-this-capture]
  229 |     std::cout << "eval not implemented for step " << currentStep_ << std::endl;
      |                                                      ^
/usr/WS2/white238/gretl/repo/src/gretl/data_store.cpp:228:24: note: add an explicit capture of 'this' to capture '*this' by reference
  228 |   evals_.emplace_back([=](const UpstreamStates&, DownstreamState&) {
      |                        ^
      |                         , this

@white238 white238 requested a review from tupek2 March 16, 2026 16:30
Comment thread src/gretl/data_store.cpp

vjps_.emplace_back([=](UpstreamStates&, const DownstreamState&) {
vjps_.emplace_back([this](UpstreamStates&, const DownstreamState&) {
std::cout << "vjp not implemented for step " << currentStep_ << std::endl;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems I should be handling error here better. but that is for another day.

@white238

Copy link
Copy Markdown
Member Author

This PR doesn't change the default C++ standard but does add a CI check to make sure it stays compatible with C++20.

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.

3 participants