MaxMatrix
Drive chained 8x8 LED dot matrix modules with MAX7219.
Loading...
Searching...
No Matches
max_matrix::internal::reference_wrapper< T > Class Template Reference

A reference to a T that is never null and owns nothing. More...

#include <reference_wrapper.h>

Public Types

using type = T

Public Member Functions

constexpr reference_wrapper (T &object)
 Makes a reference to object.
 reference_wrapper (T &&)=delete
 Deleted: a temporary would be gone before the first use.
MAXMATRIX_NODISCARD constexpr T & get () const
 Returns the object referred to.
constexpr operator T& () const
 Returns the object referred to, so that it passes as a T&.

Detailed Description

template<typename T>
class max_matrix::internal::reference_wrapper< T >

A reference to a T that is never null and owns nothing.

It is meant for a member that refers to an object another owns, as CodingStyle.md FN-15 asks: a T& member takes the assignment from the class, and a T* leaves open whether it may be null. Inside it is a pointer, 2 bytes on the Uno.

It binds an lvalue only, never a temporary, which would be gone before the first use. Assigning one rebinds it, as in the standard; to write through it, use get().

Template Parameters
TThe type referred to, const for a reference that cannot write.
Differs from the standard:
No operator(), no constructor from a reference_wrapper of another type, and no ref() or cref(): nothing in the library needs them. The address is taken with &, not as std::addressof() takes it, as no class of the project overloads unary &.

Member Typedef Documentation

◆ type

template<typename T>
using max_matrix::internal::reference_wrapper< T >::type = T

The type referred to.

Constructor & Destructor Documentation

◆ reference_wrapper() [1/2]

template<typename T>
max_matrix::internal::reference_wrapper< T >::reference_wrapper ( T & object)
inlineconstexpr

Makes a reference to object.

Implicit, as in the standard, so that a member is initialized from the object itself.

Parameters
[in]objectThe object, an lvalue.

◆ reference_wrapper() [2/2]

template<typename T>
max_matrix::internal::reference_wrapper< T >::reference_wrapper ( T && )
delete

Deleted: a temporary would be gone before the first use.

Note
Deleted rather than left out, so that a reference to T const cannot bind a temporary through the T const& of the constructor above.

Member Function Documentation

◆ operator T&()

template<typename T>
max_matrix::internal::reference_wrapper< T >::operator T& ( ) const
inlineconstexpr

Returns the object referred to, so that it passes as a T&.

Implicit, as in the standard, for a function that takes a T&.


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