move confirmation_callback_t constructors out of line and fix move semantics - #1620
Open
erics118 wants to merge 7 commits into
Open
move confirmation_callback_t constructors out of line and fix move semantics#1620erics118 wants to merge 7 commits into
erics118 wants to merge 7 commits into
Conversation
✅ Deploy Preview for dpp-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
braindigitalis
requested changes
Jul 25, 2026
braindigitalis
left a comment
Contributor
There was a problem hiding this comment.
needs comments, and we can't really just get rid of the destructors as it breaks the expectations of the managed base class.
declare special member functions out of line, so codegen is emitted once rather than in every tu
declare special members out of line for large objects (message, embed, component, user, channel, guild, slashcommand, interaction, command_option)
for json_interface only types (ban, invite, prune, dtemplate, voiceregion, voicestate, auditlog, guild_command_permissions, onboarding, application_role_connection and its nested metadata, automod_metadata) virtual destructor has to stay, and we declare rule of 5 to ensure proper move semantics for managed types, (application, integration, stage_instance, sticker, user_identified, automod_rule) the declared destructor is redundant, so we remove it, so it supports proper move semantics now, confirmation_callback_t is known to be nothrow moveable
…l member functions inline
bc previous unconditional noexcept doesn't work on msvc (bc std::map move can throw, and message has a map)
erics118
force-pushed
the
callback-constructors
branch
from
August 4, 2026 01:03
097c388 to
f995dc5
Compare
Contributor
Author
|
ill fix docs and other stuff once i figure out what actually works |
make interaction, guild out of line welcome_screen, user in-line
braindigitalis
approved these changes
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR: user-declared dtors were suppressing implicit moves, so the "moves" would copy data. this pr restores proper move semantics without removing the virtual dtors, and defines certain big class special members out of line for a much faster build (for me, 41.8s->12.6s)
previously, almost every data class declared a destructor (usually of the form
virtual ~T() = default). the existence of this user-declared dtor suppresses the implicit move constructor/move assignment, so these "moves" have been copies.this PR fixes it to have proper move semantics, and moves the definitions out of line to reduce codegen (they are now generated once, instead of in every TU).
all classes still keep their virtual destructors, so deriving from them and deleting through a base pointer is the same as before.
specifically:
json_interfaceonly types: ban, invite, prune, dtemplate, voiceregion, voicestate, auditlog, guild_command_permissions, onboarding, application_role_connection and its nested metadata, automod_metadatadefaultto get proper moves backmanagedderived types: application, integration, stage_instance, sticker, user_identified, automod_rulemanaged, so the extra dtor decl is redundant. removing it re-enables the implicit moves.by doing this, every
confirmable_talternative is nothrow moveable (except on msvc, see below), soconfirmation_callback_tis also nothrow moveable, and the REST results and coro plumbing properly move instead of copy.for the noexcept specs, two c++17 facts collide:
std::mapmove can throw, unlike libstdc++/libc++, so a type holding a map can't promise unconditional noexcept.so:
noexceptstd::mapdirectly or transitively (message viaattached_poll, interaction viaresolvedits integration-owners map and itsmsg, guild viavoice_members, interaction_response via itsmessage, confirmation_callback_t viaconfirmable_t) declare a conditional spec mirroring what the compiler would computemessage(message&&) noexcept(std::is_nothrow_move_constructible_v<std::optional<poll>>)): nothrow on gcc/clang, potentially throwing on msvc, valid everywhere= defaultcopy/move members. in-class defaulting gets the computed exception specification automatically, so the compiler produces the right spec per platform with nothing spelled outI also ran some benchmarks by compiling my bot, to see whether this out-of-lining had benefits (avg of 3 runs):
Code change checklist