xo-alloc2 xo-object: bugfix + refactor -> IGCObject_DList builds

This commit is contained in:
Roland Conybeare 2025-12-14 13:52:29 -05:00
commit 5d9345e8fd
2 changed files with 28 additions and 0 deletions

View file

@ -72,6 +72,8 @@ namespace xo {
/** OObject is truthy **/
operator bool() const { return data_ != nullptr; }
// ----- iface() for variant fat pointer -----
/** interface pointer for variant OObject instances.
* These instance support runtime polymorphism.
**/
@ -88,6 +90,18 @@ namespace xo {
return std::launder(&iface_);
}
/** non-const verison. Technically all interface methods are const.
* But counterintuitive to have to mark interface methods const
* that are dedicated to mutable data.
**/
FacetType * iface()
requires std::is_same_v<DataType, DVariantPlaceholder>
{
return std::launder(&iface_);
}
// ----- iface() for typed fat pointer -----
/** interface pointer for OObject instance with representation
* known at compile time.
*
@ -102,6 +116,16 @@ namespace xo {
return &iface_;
}
/** non-const verison. Technically all interface methods are const.
* But counterintuitive to have to mark interface methods const
* that are dedicated to mutable data.
**/
FacetType * iface()
requires(!std::is_same_v<DataType, DVariantPlaceholder>)
{
return &iface_;
}
DataPtr data() const { return data_; }
void reset() { data_ = nullptr; }

View file

@ -12,6 +12,10 @@ namespace xo {
template <typename RRouter>
consteval bool valid_object_router()
{
static_assert(sizeof(RRouter) >= sizeof(RRouter::ObjectType),
"Router type must inherit Router::ObjectType");
static_assert(std::is_convertible_v<RRouter, typename RRouter::ObjectType>,
"Router type must inherit Router::ObjectType");
static_assert(requires { typename RRouter::ObjectType; },
"Router type must provide typename Router::ObjectType");
static_assert(valid_object_traits<RRouter::ObjectType>,