FastLED 3.10.8
Loading...
Searching...
No Matches
functional.h
Go to the documentation of this file.
1#pragma once
4#include "fl/stl/noexcept.h"
5
6namespace fl {
7
8template <typename T, typename Deleter>
9class unique_ptr; // Forward declare unique_ptr to avoid header inclusion
10
11//----------------------------------------------------------------------------
12// invoke implementation - equivalent to std::invoke from C++17
13//----------------------------------------------------------------------------
14
15namespace detail {
16
17// Helper to detect member data pointers
18template <typename T>
20
21template <typename T, typename C>
22struct is_member_data_pointer<T C::*> : integral_constant<bool, !is_function<T>::value> {};
23
24// Helper to detect if T is a pointer type
25template <typename T>
27
28template <typename T>
29struct is_pointer_like<T*> : true_type {};
30
31template <typename T, typename Deleter>
32struct is_pointer_like<fl::unique_ptr<T, Deleter>> : true_type {};
33
34// Helper to detect if we should use pointer-to-member syntax
35template <typename T>
36struct use_pointer_syntax : is_pointer_like<typename remove_reference<T>::type> {};
37
38} // namespace detail
39
40namespace adl_barrier { // see fl/stl/adl_barrier.h
41// Main invoke function overloads
42
43// 1a. Member function pointer with object reference
44template <typename F, typename T1, typename... Args>
52
53// 1b. Member function pointer with pointer-like object
54template <typename F, typename T1, typename... Args>
55auto invoke(F&& f, T1&& t1, Args&&... args) FL_NO_EXCEPT
58 decltype(((*fl::forward<T1>(t1)).*f)(fl::forward<Args>(args)...))>
59{
60 return ((*fl::forward<T1>(t1)).*f)(fl::forward<Args>(args)...);
61}
62
63// 2a. Member data pointer with object reference
64template <typename F, typename T1>
72
73// 2b. Member data pointer with pointer-like object
74template <typename F, typename T1>
75auto invoke(F&& f, T1&& t1) FL_NO_EXCEPT
78 decltype((*fl::forward<T1>(t1)).*f)>
79{
80 return (*fl::forward<T1>(t1)).*f;
81}
82
83// 3. Regular callable (function pointer, lambda, functor)
84template <typename F, typename... Args>
92} // namespace adl_barrier
93
94} // namespace fl
Keeps fl's generic templates out of argument-dependent lookup (ADL).
auto invoke(F &&f, T1 &&t1, Args &&... args) FL_NO_EXCEPT -> enable_if_t< is_member_function_pointer< typename remove_reference< F >::type >::value &&!detail::use_pointer_syntax< T1 >::value, decltype((fl::forward< T1 >(t1).*f)(fl::forward< Args >(args)...))>
Definition functional.h:45
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_info.h:57
constexpr T && forward(typename remove_reference< T >::type &t) FL_NO_EXCEPT
Definition s16x16x4.h:236
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
constexpr int type_rank< T >::value
integral_constant< bool, false > false_type
Definition type_traits.h:29
typename enable_if< Condition, T >::type enable_if_t
Definition type_traits.h:67
integral_constant< bool, true > true_type
Definition type_traits.h:28
Base definition for an LED controller.
corkscrew_args args
Definition old.h:149