Skip to content

move confirmation_callback_t constructors out of line and fix move semantics - #1620

Open
erics118 wants to merge 5 commits into
brainboxdotcc:devfrom
erics118:callback-constructors
Open

move confirmation_callback_t constructors out of line and fix move semantics#1620
erics118 wants to merge 5 commits into
brainboxdotcc:devfrom
erics118:callback-constructors

Conversation

@erics118

Copy link
Copy Markdown
Contributor

we fix move semantics for two types of classes:

  • 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
  • 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

confirmation_callback_t special member functions are moved out of line so codegen is emitted once rather than in every translation unit, saving compile time (for ppl using the library, no big change to DPP compile times)

similarly, we also move special member functions for message, embed, component, user, channel, guild, slashcommand, interaction, command_option out of line to also save compile time

Code change checklist

  • I have ensured that all methods and functions are fully documented using doxygen style comments.
  • My code follows the coding style guide.
  • I tested that my change works before raising the PR.
  • I have ensured that I did not break any existing API calls.
  • I have not built my pull request using AI, a static analysis tool or similar without any human oversight.

erics118 added 3 commits July 23, 2026 15:25
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
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for dpp-dev ready!

Name Link
🔨 Latest commit 097c388
🔍 Latest deploy log https://app.netlify.com/projects/dpp-dev/deploys/6a630123289f740008632ece
😎 Deploy Preview https://deploy-preview-1620--dpp-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added documentation Improvements or additions to documentation code Improvements or additions to code. labels Jul 23, 2026
erics118 added 2 commits July 23, 2026 17:35
msvc computes noexcept(false) always, so this would be incorrect on msvc
no change for all others

@braindigitalis braindigitalis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

needs comments, and we can't really just get rid of the destructors as it breaks the expectations of the managed base class.

Comment thread include/dpp/appcommand.h
interaction_response() = default;
interaction_response(const interaction_response&);
interaction_response(interaction_response&&);
interaction_response& operator=(const interaction_response&);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

documentation needed

Comment thread include/dpp/appcommand.h
*/
interaction();

interaction(const interaction&) = default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

documentation needed

Comment thread include/dpp/appcommand.h
@@ -1415,6 +1429,11 @@ class DPP_EXPORT guild_command_permissions : public json_interface<guild_command
*/
guild_command_permissions();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

documentation needed

Comment thread include/dpp/appcommand.h
*/
slashcommand(const std::string &_name, const slashcommand_contextmenu_type _type, const dpp::snowflake _application_id);

slashcommand(const slashcommand&) = default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

documentation needed

Comment thread include/dpp/automod.h
*/
automod_metadata();

automod_metadata(const automod_metadata&) = default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

documentation needed

Comment thread include/dpp/ban.h
/** Constructor */
ban();

ban(const ban&) = default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

documentation needed

Comment thread include/dpp/integration.h
integration();

/** Default destructor */
~integration() = default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if it is managed a user could choose to put it in a cache. without the virtual dtor, that becomes ub.

Comment thread include/dpp/message.h
*/
sticker();

virtual ~sticker() = default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here user could choose to cache it with a custom cache. that's the point of managed

Comment thread include/dpp/prune.h
public:
prune() = default;

prune(const prune&) = default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

documentation needed

Comment thread include/dpp/restresults.h
confirmation_callback_t() = default;
confirmation_callback_t();

confirmation_callback_t(const confirmation_callback_t&);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

documentation needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code Improvements or additions to code. documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants