FastArduino  v1.8
C++ library to build fast but small Arduino/AVR projects
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.
 
using TREF = TREF_
 The reference type of item wrapped by this class.
 
using CTREF = CTREF_
 The constant reference type of item wrapped by this class.
 

Public Member Functions

 LinkWrapper (const LinkWrapper< T_, TREF_, CTREF_ > &)=default
 
LinkWrapper< T_, TREF_, CTREF_ > & operator= (const LinkWrapper< T_, TREF_, CTREF_ > &)=delete
 
 LinkWrapper (CTREF item)
 Create a wrapper, usable in a LinkedList, for item.
 
TREF item ()
 Return a reference to the wrapped item.
 
CTREF item () const
 Return a constant reference to the wrapped item.
 

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>;
LinkedList<LINK> list;
LINK item1 = LINK{MyType{...}};
list.insert(item1);
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 223 of file linked_list.h.


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