FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
containers::LinkWrapper< T_, TREF_, CTREF_ > Class Template Reference

A wrapper for items stored in a LinkedList. More...

#include <fastarduino/linked_list.h>

Inheritance diagram for containers::LinkWrapper< T_, TREF_, CTREF_ >:
Collaboration diagram for containers::LinkWrapper< T_, TREF_, CTREF_ >:

Public Types

using T = T_
 The type of item wrapped by this class. More...
 
using TREF = TREF_
 The reference type of item wrapped by this class. More...
 
using CTREF = CTREF_
 The constant reference type of item wrapped by this class. More...
 

Public Member Functions

 LinkWrapper (const LinkWrapper &)=delete
 
LinkWrapperoperator= (const LinkWrapper &)=delete
 
 LinkWrapper (CTREF item)
 Create a wrapper, usable in a LinkedList, for item. More...
 
TREF item ()
 Return a reference to the wrapped item. More...
 
CTREF item () const
 Return a constant reference to the wrapped item. More...
 

Friends

class LinkedList< TYPE >
 
template<class T , class B >
struct types_traits::derives_from
 

Detailed Description

template<typename T_, typename TREF_ = T_&, typename CTREF_ = const T_&>
class containers::LinkWrapper< T_, TREF_, CTREF_ >

A wrapper for items stored in a LinkedList.

Contrarily to Link class, you may wrap any existing type (even a simple type such as bool, uint16_t, char...)

The follwoing snippet shows how to use this class:

class MyType {...};
using LINK = LinkWrapper<MyType>;
LINK item1 = LINK{MyType{...}};
list.insert(item1);
Linked list of type T_ items.
Definition: linked_list.h:81
void insert(T &item) INLINE
Insert item at the beginning of this list.
Definition: linked_list.h:103
Template Parameters
T_the type of item wrapped by this class
TREF_the default reference type to T_
TREF_the reference type of items wrapped; this is T_& by default, but this may be changed, for small size types (one or two bytes long) to T_ itself, in order to avoid additional code to handle reference extraction of an item.
CTREF_the constant reference type of items wrapped; this is const T_& by default, but this may be changed, for small size types (one or two bytes long) to T_ itself, in order to avoid additional code to handle reference extraction of an item.
See also
LinkedList
Link

Definition at line 218 of file linked_list.h.

Member Typedef Documentation

◆ T

template<typename T_ , typename TREF_ = T_&, typename CTREF_ = const T_&>
using containers::LinkWrapper< T_, TREF_, CTREF_ >::T = T_

The type of item wrapped by this class.

Definition at line 225 of file linked_list.h.

◆ TREF

template<typename T_ , typename TREF_ = T_&, typename CTREF_ = const T_&>
using containers::LinkWrapper< T_, TREF_, CTREF_ >::TREF = TREF_

The reference type of item wrapped by this class.

Definition at line 228 of file linked_list.h.

◆ CTREF

template<typename T_ , typename TREF_ = T_&, typename CTREF_ = const T_&>
using containers::LinkWrapper< T_, TREF_, CTREF_ >::CTREF = CTREF_

The constant reference type of item wrapped by this class.

Definition at line 231 of file linked_list.h.

Constructor & Destructor Documentation

◆ LinkWrapper()

template<typename T_ , typename TREF_ = T_&, typename CTREF_ = const T_&>
containers::LinkWrapper< T_, TREF_, CTREF_ >::LinkWrapper ( CTREF  item)
inline

Create a wrapper, usable in a LinkedList, for item.

Definition at line 236 of file linked_list.h.

Member Function Documentation

◆ item() [1/2]

template<typename T_ , typename TREF_ = T_&, typename CTREF_ = const T_&>
TREF containers::LinkWrapper< T_, TREF_, CTREF_ >::item ( )
inline

Return a reference to the wrapped item.

Definition at line 241 of file linked_list.h.

◆ item() [2/2]

template<typename T_ , typename TREF_ = T_&, typename CTREF_ = const T_&>
CTREF containers::LinkWrapper< T_, TREF_, CTREF_ >::item ( ) const
inline

Return a constant reference to the wrapped item.

Definition at line 249 of file linked_list.h.

Friends And Related Function Documentation

◆ LinkedList< TYPE >

template<typename T_ , typename TREF_ = T_&, typename CTREF_ = const T_&>
friend class LinkedList< TYPE >
friend

Definition at line 262 of file linked_list.h.

◆ types_traits::derives_from

template<typename T_ , typename TREF_ = T_&, typename CTREF_ = const T_&>
template<class T , class B >
friend struct types_traits::derives_from
friend

Definition at line 265 of file linked_list.h.


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