From 2c4e151343828af13b28ec39946b6bf34748c2b3 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 24 Apr 2025 20:12:26 +0200 Subject: adw: extract class definitions --- include/adwaitamm/helpers/gobj_mixin.hpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'include/adwaitamm/helpers/gobj_mixin.hpp') diff --git a/include/adwaitamm/helpers/gobj_mixin.hpp b/include/adwaitamm/helpers/gobj_mixin.hpp index fbdaa4e..762136e 100644 --- a/include/adwaitamm/helpers/gobj_mixin.hpp +++ b/include/adwaitamm/helpers/gobj_mixin.hpp @@ -8,27 +8,35 @@ namespace Adwaita::helpers { - template + template + struct copy_const + { + using type = TargetType; + }; + + template + struct copy_const + { + using type = std::add_const_t; + }; + + template + using copy_const_t = typename copy_const::type; + + template struct gobj_mixin { template auto gobj(this Self && self) noexcept { - using clean_type = std::remove_reference_t; - using gobj_type = std::conditional_t, std::add_const_t, Glib::Object>; - using cast_type = std::conditional_t, std::add_const_t, AdwType>; - - return reinterpret_cast(static_cast(self).gobj()); + using base_type = copy_const_t, BaseType>; + return reinterpret_cast(self.::Glib::Object::gobj()); } template - auto gobj_copy(this Self && self) noexcept -> AdwType * + auto gobj_copy(this Self && self) noexcept { - using clean_type = std::remove_reference_t; - using gobj_type = std::conditional_t, std::add_const_t, Glib::Object>; - - static_cast(self).reference(); - return const_cast(self.gobj()); + return reinterpret_cast(self.::Glib::Object::gobj_copy()); } }; -- cgit v1.2.3