MaxMatrix
Drive chained 8x8 LED dot matrix modules with MAX7219.
Loading...
Searching...
No Matches
reference_wrapper.h
Go to the documentation of this file.
1// Copyright 2026 Andreas Burnickl
2// SPDX-License-Identifier: GPL-3.0-or-later
3
9
10#ifndef MAXMATRIX_SRC_UTILITY_REFERENCE_WRAPPER_H_
11#define MAXMATRIX_SRC_UTILITY_REFERENCE_WRAPPER_H_
12
13#include "MaxMatrixAttributes.h"
14
15namespace max_matrix {
16namespace internal {
17
37/*
38 * MaxMatrix's own, by CodingStyle.md M-3: avr-gcc brings no <functional>, and
39 * MaxMatrix depends on neither the ETL nor Utl, whose utl::reference_wrapper
40 * this follows (OIL 28, 41).
41 */
42template <typename T>
44 public:
45 using type = T;
46
55 constexpr reference_wrapper(T& object) // NOLINT(runtime/explicit): as std
56 : pointer_{&object} {}
57
64 reference_wrapper(T&&) = delete; // NOLINT(runtime/explicit): never called
65
67 MAXMATRIX_NODISCARD constexpr T& get() const { return *pointer_; }
68
74 constexpr operator T&() const { return *pointer_; }
75
76 private:
77 T* pointer_;
78};
79
80} // namespace internal
81} // namespace max_matrix
82
83#endif // MAXMATRIX_SRC_UTILITY_REFERENCE_WRAPPER_H_
The attributes of a later standard, as macros, where the compiler has them.
#define MAXMATRIX_NODISCARD
Marks a function whose result must not be dropped: the compiler warns where it is.
Definition MaxMatrixAttributes.h:37
MAXMATRIX_NODISCARD constexpr T & get() const
Returns the object referred to.
Definition reference_wrapper.h:67
constexpr reference_wrapper(T &object)
Makes a reference to object.
Definition reference_wrapper.h:55
T type
Definition reference_wrapper.h:45
reference_wrapper(T &&)=delete
Deleted: a temporary would be gone before the first use.