5 #ifndef EASTL_FIXED_FUNCTION_H
6 #define EASTL_FIXED_FUNCTION_H
8 #if defined(EA_PRAGMA_ONCE_SUPPORTED)
12 #include <EASTL/internal/function_detail.h>
16 template <
int,
typename>
25 template <
int SIZE_IN_BYTES,
typename R,
typename... Args>
33 #define EASTL_INTERNAL_FIXED_FUNCTION_STATIC_ASSERT(TYPE) \
34 static_assert(sizeof(TYPE) <= sizeof(typename Base::FunctorStorageType), \
35 "fixed_function local buffer is not large enough to hold the callable object.")
37 #define EASTL_INTERNAL_FIXED_FUNCTION_NEW_SIZE_STATIC_ASSERT(NEW_SIZE_IN_BYTES) \
38 static_assert(SIZE_IN_BYTES >= NEW_SIZE_IN_BYTES, \
39 "fixed_function local buffer is not large enough to hold the new fixed_function type.")
41 template <
typename Functor>
42 using EASTL_DISABLE_OVERLOAD_IF_FIXED_FUNCTION =
43 eastl::disable_if_t<internal::is_fixed_function_v<eastl::decay_t<Functor>>>;
48 template <
int SIZE_IN_BYTES,
typename R,
typename... Args>
54 using typename Base::result_type;
72 template <
typename Functor,
73 typename = EASTL_INTERNAL_FUNCTION_VALID_FUNCTION_ARGS(Functor, R, Args...,
Base,
fixed_function),
74 typename = EASTL_DISABLE_OVERLOAD_IF_FIXED_FUNCTION<Functor>>
78 EASTL_INTERNAL_FIXED_FUNCTION_STATIC_ASSERT(Functor);
81 template<
int NEW_SIZE_IN_BYTES>
85 EASTL_INTERNAL_FIXED_FUNCTION_NEW_SIZE_STATIC_ASSERT(NEW_SIZE_IN_BYTES);
88 template<
int NEW_SIZE_IN_BYTES>
92 EASTL_INTERNAL_FIXED_FUNCTION_NEW_SIZE_STATIC_ASSERT(NEW_SIZE_IN_BYTES);
99 Base::operator=(other);
115 template<
int NEW_SIZE_IN_BYTES>
118 EASTL_INTERNAL_FIXED_FUNCTION_NEW_SIZE_STATIC_ASSERT(NEW_SIZE_IN_BYTES);
120 Base::operator=(other);
124 template<
int NEW_SIZE_IN_BYTES>
127 EASTL_INTERNAL_FIXED_FUNCTION_NEW_SIZE_STATIC_ASSERT(NEW_SIZE_IN_BYTES);
133 template <
typename Functor,
134 typename = EASTL_INTERNAL_FUNCTION_VALID_FUNCTION_ARGS(Functor, R, Args...,
Base,
fixed_function),
135 typename = EASTL_DISABLE_OVERLOAD_IF_FIXED_FUNCTION<Functor>>
138 EASTL_INTERNAL_FIXED_FUNCTION_STATIC_ASSERT(eastl::decay_t<Functor>);
139 Base::operator=(eastl::forward<Functor>(functor));
143 template <
typename Functor>
156 explicit operator bool()
const EA_NOEXCEPT
158 return Base::operator bool();
161 R operator ()(Args... args)
const
163 return Base::operator ()(eastl::forward<Args>(args)...);
166 #if EASTL_RTTI_ENABLED
167 const std::type_info& target_type()
const EA_NOEXCEPT
169 return Base::target_type();
172 template <
typename Functor>
173 Functor* target() EA_NOEXCEPT
175 return Base::target();
178 template <
typename Functor>
179 const Functor* target()
const EA_NOEXCEPT
181 return Base::target();
186 template <
int S,
typename R,
typename... Args>
187 bool operator==(
const fixed_function<S, R(Args...)>& f, std::nullptr_t) EA_NOEXCEPT
192 template <
int S,
typename R,
typename... Args>
193 bool operator==(std::nullptr_t,
const fixed_function<S, R(Args...)>& f) EA_NOEXCEPT
198 template <
int S,
typename R,
typename... Args>
199 bool operator!=(
const fixed_function<S, R(Args...)>& f, std::nullptr_t) EA_NOEXCEPT
204 template <
int S,
typename R,
typename... Args>
205 bool operator!=(std::nullptr_t,
const fixed_function<S, R(Args...)>& f) EA_NOEXCEPT
210 template <
int S,
typename R,
typename... Args>
211 void swap(fixed_function<S, R(Args...)>& lhs, fixed_function<S, R(Args...)>& rhs)
Definition: fixed_function.h:17
Definition: function_detail.h:420
Definition: function_detail.h:416
reference_wrapper
Definition: functional_base.h:221
EA Standard Template Library.
Definition: algorithm.h:288
OutputIterator move(InputIterator first, InputIterator last, OutputIterator result)
Definition: copy_help.h:170
Definition: type_traits.h:263
Definition: fixed_function.h:23