31template<
typename T,
typename Interface>
33 std::is_convertible_v<T*, Interface*>;
59 template<
typename Interface,
typename Impl>
60 static std::shared_ptr<Interface>
make_adapter(std::shared_ptr<Impl> impl) {
63 return std::static_pointer_cast<Interface>(impl);
66 return std::make_shared<interface_adapter<Interface, Impl>>(impl);
81 template<
typename AdapterType,
typename... Args>
83 return std::make_shared<AdapterType>(std::forward<Args>(args)...);
97 template<
typename T,
typename Interface>
98 static std::shared_ptr<T>
try_unwrap(std::shared_ptr<Interface> ptr) {
119 template<
typename Interface,
typename Impl>
139template<
typename Interface,
typename Impl>
156template<
typename T,
typename Interface>
157std::shared_ptr<T>
unwrap_adapter(std::shared_ptr<Interface> ptr) {
Adapter traits and base class for type-erased cross-system wrappers.
Smart adapter factory that avoids unnecessary wrapping.
static std::shared_ptr< Interface > make_adapter(std::shared_ptr< Impl > impl)
Create an adapter with automatic optimization.
static std::shared_ptr< AdapterType > make_explicit_adapter(Args &&... args)
Create an adapter with explicit adapter type.
static constexpr bool is_zero_cost()
Check if zero-cost adaptation is possible.
static std::shared_ptr< T > try_unwrap(std::shared_ptr< Interface > ptr)
Try to unwrap an interface to get underlying implementation.
std::shared_ptr< T > unwrap_adapter(std::shared_ptr< Interface > ptr)
Convenience function for unwrapping adapters.
std::shared_ptr< Interface > make_smart_adapter(std::shared_ptr< Impl > impl)
Convenience function for creating smart adapters.
std::shared_ptr< T > safe_unwrap(std::shared_ptr< Interface > ptr)
Helper function to safely unwrap an adapter.
constexpr bool implements_interface_v
Type trait to check if a type implements an interface.