From 471188806aa43f63df20b688517c23288af1264d Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Thu, 14 Aug 2025 15:23:28 -0600 Subject: [PATCH] :sparkles: Add optional tombstones for product types Problem: - Product types cannot easily be put into `stdx::optional` without specifying a separate tombstone value. Solution: - If the types inside the product already have tombstone values, use them. --- include/stdx/optional.hpp | 16 ++++++++++++++++ test/optional.cpp | 35 ++++++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/include/stdx/optional.hpp b/include/stdx/optional.hpp index 042b64d..f631420 100644 --- a/include/stdx/optional.hpp +++ b/include/stdx/optional.hpp @@ -23,6 +23,11 @@ template struct tombstone_traits { } }; +template constexpr auto has_tombstone_v = true; +template +constexpr auto has_tombstone_v< + T, std::void_t::unspecialized>> = false; + template struct tombstone_traits>> { constexpr auto operator()() const { @@ -35,6 +40,17 @@ struct tombstone_traits>> { constexpr auto operator()() const { return nullptr; } }; +template