mc_rtc::shared< T, BaseT > Struct Template Reference

#include <mc_rtc/shared.h>

Inheritance diagram for mc_rtc::shared< T, BaseT >:
Collaboration diagram for mc_rtc::shared< T, BaseT >:

Public Types

using ActualBase = typename std::conditional< std::is_same< BaseT, void >::value, std::enable_shared_from_this< T >, BaseT >::type
 

Public Member Functions

 operator std::shared_ptr< T > ()
 
 operator std::shared_ptr< const T > () const
 

Detailed Description

template<typename T, typename BaseT = void>
struct mc_rtc::shared< T, BaseT >

This template helper allow to enable implicit conversion from instances of T (resp. const T) to std::shared_ptr<T> (resp. std::shared_ptr<const T>).

This allows mc_rtc to expose reference (or const reference) to internal objects stored as pointer which are often manipulated without requiring ownership or access a "nested" object without incurring extra pointer copies (e.g. accessing a frame of a robot).

Template Parameters
TThe type that should be shared
BaseTIf provided BaseT must inherit shared<BaseT>. shared<T, BaseT> then inherits BaseT with added conversions for T

Member Typedef Documentation

◆ ActualBase

template<typename T , typename BaseT = void>
using mc_rtc::shared< T, BaseT >::ActualBase = typename std::conditional<std::is_same<BaseT, void>::value, std::enable_shared_from_this<T>, BaseT>::type

Inherit constructors from the base

Member Function Documentation

◆ operator std::shared_ptr< const T >()

template<typename T , typename BaseT = void>
mc_rtc::shared< T, BaseT >::operator std::shared_ptr< const T > ( ) const
inline

◆ operator std::shared_ptr< T >()

template<typename T , typename BaseT = void>
mc_rtc::shared< T, BaseT >::operator std::shared_ptr< T > ( )
inline

The documentation for this struct was generated from the following file: