Skip to content

Mark destructors as constexpr for C++20 - #181

Open
dengzhongyuan365-dev wants to merge 1 commit into
TartanLlama:masterfrom
dengzhongyuan365-dev:fix/issue-104-constexpr-destructors
Open

Mark destructors as constexpr for C++20#181
dengzhongyuan365-dev wants to merge 1 commit into
TartanLlama:masterfrom
dengzhongyuan365-dev:fix/issue-104-constexpr-destructors

Conversation

@dengzhongyuan365-dev

Copy link
Copy Markdown

Summary

  • Mark all user-defined destructors in expected_storage_base as constexpr for C++20, enabling tl::expected to be used in compile-time contexts (consteval/constexpr)

Changes

File Change
include/tl/expected.hpp Added TL_EXPECTED_20_CONSTEXPR macro; applied it to 4 user-defined destructors

Test Plan

  • Built with CMake (CMAKE_CXX_STANDARD=20) — compiles cleanly
  • All 454 assertions in 39 test cases pass
  • = default destructors left unchanged (compiler handles them automatically)

Fixes #104

C++20 allows constexpr destructors (P0718R2). This enables
tl::expected to be used in compile-time contexts (consteval/constexpr).

Add TL_EXPECTED_20_CONSTEXPR macro and apply it to all user-defined
destructors in expected_storage_base specializations.

Fixes TartanLlama#104
@dengzhongyuan365-dev
dengzhongyuan365-dev marked this pull request as ready for review June 30, 2026 11:13
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.

Mark destructors as constexpr

1 participant