.. index:: pair: class; EE::SmallUniqueFunction .. _doxid-class_e_e_1_1_small_unique_function_3_01_r_07_args_8_8_8_08_00_01_inline_size_01_4: template class EE::SmallUniqueFunction ============================================================== .. toctree:: :hidden: struct_EE_SmallUniqueFunction_SmallUniqueFunction.rst Overview ~~~~~~~~ Move-only type-erased callable with inline storage and a heap fallback. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class SmallUniqueFunction { public: // structs template <> struct :ref:`SmallUniqueFunction`; // construction :target:`SmallUniqueFunction`(); :target:`SmallUniqueFunction`(std::nullptr_t); :target:`SmallUniqueFunction`(const :ref:`SmallUniqueFunction`&); :target:`SmallUniqueFunction`(:ref:`SmallUniqueFunction`&& other); template , std::enable_if_t&&std::is_invocable_r_v, int> = 0> :target:`SmallUniqueFunction`(Callable&& callable); :target:`~SmallUniqueFunction`(); // methods :ref:`SmallUniqueFunction`& :target:`operator=`(const :ref:`SmallUniqueFunction`&); :ref:`SmallUniqueFunction`& :target:`operator=`(:ref:`SmallUniqueFunction`&& other); template , std::enable_if_t&&std::is_invocable_r_v, int> = 0> :ref:`SmallUniqueFunction`& :target:`operator=`(Callable&& callable); :ref:`SmallUniqueFunction`& :target:`operator=`(std::nullptr_t); :target:`operator bool`() const; R :target:`operator()`(Args... args); void :target:`reset`(); bool :ref:`isInline`() const; static constexpr std::size_t :target:`inlineSize`(); }; .. _details-class_e_e_1_1_small_unique_function_3_01_r_07_args_8_8_8_08_00_01_inline_size_01_4: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Move-only type-erased callable with inline storage and a heap fallback. Unlike :ref:`SmallFunction `, the stored callable only needs to be move-constructible, which allows closures that own move-only state (tasks, unique pointers, file handles) to be queued on executors without wrapping them in shared heap holders. Callables larger than InlineSize, or whose alignment or move constructor make inline relocation unsafe, are stored on the heap. The callable is invoked as a non-const lvalue: it may mutate its captures, and the object can be invoked more than once unless the stored callable itself consumes its state. Methods ------- .. index:: pair: function; isInline .. _doxid-class_e_e_1_1_small_unique_function_3_01_r_07_args_8_8_8_08_00_01_inline_size_01_4_1a0639a9e0822c1306f816b994f8d44c47: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool isInline() const .. rubric:: Returns: True when the stored callable lives in the inline buffer.