Skip to content

Conversation

@rgacogne
Copy link
Member

@rgacogne rgacogne commented Dec 8, 2025

Short description

Checklist

I have:

  • read the CONTRIBUTING.md document
  • read and accepted the Developer Certificate of Origin document, including the AI Policy, and added a "Signed-off-by" to my commits
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)


static PushedObject push(lua_State* state, const std::variant<TTypes...>& value) noexcept {
PushedObject obj{state, 0};
std::visit([&](auto&& arg) {
Copy link
Member

Choose a reason for hiding this comment

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

does this bump the luawrapper C++ requirement to C++17? Because in theory we try to stay in sync with upstream (which is me and I haven't spoken to any other users in years)

Copy link
Member Author

Choose a reason for hiding this comment

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

It does, std::variant is a C++17 feature.

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that we added support for std::optional which is also a C++17 feature, so technically we already bumped it (oops :-/).

Copy link
Member

Choose a reason for hiding this comment

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

oh, duh. I checked std::visit which is ++17, but that is of course obvious if variant itself is. Carry on :)

Copy link
Member

Choose a reason for hiding this comment

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

Note that we added support for std::optional which is also a C++17 feature, so technically we already bumped it (oops :-/).

Right. No way back then. Do what feels good :)

Copy link
Member

Choose a reason for hiding this comment

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

I think it's good to keep in mind that this is possible if necessary, but I don't think we need to uglify the code with it now.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we might get away with something like:

template<class Type>
#if __cplusplus >= 201703L
using OptionalValue = std::optional<Type>;
#else
using OptionalValue = boost::optional<Type>;
#endif

Copy link
Member

Choose a reason for hiding this comment

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

ok, if it's that easy, why not :)

Copy link
Contributor

Choose a reason for hiding this comment

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

unless the caller uses boost::optional :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I pushed a commit fixing C++11 compatibility for now.

{
constexpr auto nbTypes = std::variant_size_v<ReturnType>;
if constexpr (I >= nbTypes) {
return boost::none;
Copy link
Member

Choose a reason for hiding this comment

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

you can take the variant out of the boost but you can't take the boost out of the luawrapper ;)

using ReturnType = std::variant<TTypes...>;

private:
template<std::size_t I = 0> static boost::optional<ReturnType> variantRead(lua_State* state, int index)
Copy link
Member

Choose a reason for hiding this comment

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

I see we do support std::optional in luawrapper now, but you can't use it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could, but we need to convert all readers at the same time, so perhaps in a follow-up PR?

Copy link
Member

Choose a reason for hiding this comment

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

right, I feared something like that

Habbie
Habbie previously approved these changes Dec 8, 2025
@coveralls
Copy link

coveralls commented Dec 8, 2025

Pull Request Test Coverage Report for Build 20058059008

Details

  • 48 of 48 (100.0%) changed or added relevant lines in 1 file are covered.
  • 62 unchanged lines in 11 files lost coverage.
  • Overall coverage decreased (-0.007%) to 73.334%

Files with Coverage Reduction New Missed Lines %
pdns/backends/gsql/gsqlbackend.hh 1 97.77%
pdns/validate.cc 1 68.5%
pdns/recursordist/aggressive_nsec.cc 2 66.39%
pdns/recursordist/rec-eventtrace.hh 2 57.01%
pdns/opensslsigners.cc 3 61.27%
pdns/remote_logger.cc 3 58.62%
pdns/misc.cc 4 61.28%
pdns/signingpipe.cc 5 85.79%
pdns/packethandler.cc 8 72.4%
pdns/recursordist/syncres.cc 12 80.99%
Totals Coverage Status
Change from base Build 20030196616: -0.007%
Covered Lines: 128842
Relevant Lines: 164907

💛 - Coveralls

@rgacogne rgacogne marked this pull request as ready for review December 11, 2025 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants