FastLED 3.9.15
Loading...
Searching...
No Matches
scope_exit.h
Go to the documentation of this file.
1#pragma once
2
8
10#include "fl/stl/noexcept.h"
11
12namespace fl {
13
16template <typename EF>
18public:
19 template <typename EFP>
20 explicit scope_exit(EFP &&f)
21 : mExitFunction(fl::forward<EFP>(f)), mActive(true) {}
22
24 : mExitFunction(fl::move(rhs.mExitFunction)), mActive(rhs.mActive) {
25 rhs.release();
26 }
27
31
33 if (mActive) {
35 }
36 }
37
38 void release() FL_NOEXCEPT { mActive = false; }
39
40private:
42 bool mActive;
43};
44
47template <typename EF>
51
52} // namespace fl
scope_exit(const scope_exit &) FL_NOEXCEPT=delete
scope_exit(scope_exit &&rhs) FL_NOEXCEPT
Definition scope_exit.h:23
scope_exit & operator=(scope_exit &&) FL_NOEXCEPT=delete
scope_exit & operator=(const scope_exit &) FL_NOEXCEPT=delete
void release() FL_NOEXCEPT
Definition scope_exit.h:38
scope_exit(EFP &&f)
Definition scope_exit.h:20
RAII guard that executes a callable when destroyed.
Definition scope_exit.h:17
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
Definition s16x16x4.h:234
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
Definition s16x16x4.h:28
scope_exit< decay_t< EF > > make_scope_exit(EF &&f)
Factory for C++11/14 (no CTAD).
Definition scope_exit.h:48
constexpr T && forward(typename remove_reference< T >::type &t) FL_NOEXCEPT
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT