diff --git a/include/xo/facet/OObject.hpp b/include/xo/facet/OObject.hpp index 7c87a66..1f46fad 100644 --- a/include/xo/facet/OObject.hpp +++ b/include/xo/facet/OObject.hpp @@ -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 + { + 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) + { + return &iface_; + } + DataPtr data() const { return data_; } void reset() { data_ = nullptr; } diff --git a/include/xo/facet/RRouter.hpp b/include/xo/facet/RRouter.hpp index daa7887..56e521d 100644 --- a/include/xo/facet/RRouter.hpp +++ b/include/xo/facet/RRouter.hpp @@ -12,6 +12,10 @@ namespace xo { template consteval bool valid_object_router() { + static_assert(sizeof(RRouter) >= sizeof(RRouter::ObjectType), + "Router type must inherit Router::ObjectType"); + static_assert(std::is_convertible_v, + "Router type must inherit Router::ObjectType"); static_assert(requires { typename RRouter::ObjectType; }, "Router type must provide typename Router::ObjectType"); static_assert(valid_object_traits,