QuickCppLib 0.10
Eliminate all the tedious hassle when making state-of-the-art C++ 14 - 23 libraries!
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
quickcpplib::_xxx::function_ptr Namespace Reference

The namespace for the function pointer type. More...

Classes

class  function_ptr
 A move only lightweight std::function alternative, with configurable small object optimisation. More...
 
class  function_ptr< R(Args...), callable_storage_bytes >
 

Functions

template<class ErasedPrototype , class Callable , size_t callable_storage_bytes = default_callable_storage_bytes, class... CallableConstructionArgs>
constexpr function_ptr< ErasedPrototype, callable_storage_bytes > emplace_function_ptr (CallableConstructionArgs &&... args)
 Return a function_ptr<ErasedPrototype> by emplacing Callable(CallableConstructionArgs...). If Callable is nothrow move constructible and sufficiently small, avoids dynamic memory allocation.
 
template<class ErasedPrototype , class Callable , class... CallableConstructionArgs>
constexpr function_ptr< ErasedPrototype,(sizeof(Callable)+sizeof(void *)+sizeof(void *) - 1) &~(sizeof(void *) - 1)> emplace_function_ptr_nothrow (CallableConstructionArgs &&... args) noexcept
 Return a function_ptr<ErasedPrototype> by emplacing Callable(CallableConstructionArgs...), without dynamically allocating memory. Note that the size of function ptr returned will be exactly the amount to store the callable, which may not be the default size of function_ptr<ErasedPrototype>.
 
template<class ErasedPrototype , class Callable , size_t callable_storage_bytes = default_callable_storage_bytes>
constexpr function_ptr< ErasedPrototype, callable_storage_bytes > make_function_ptr (Callable &&f)
 Return a function_ptr<ErasedPrototype> by from an input Callable. If Callable is nothrow move constructible and sufficiently small, avoids dynamic memory allocation.
 
template<class ErasedPrototype , class Callable >
constexpr auto make_function_ptr_nothrow (Callable &&f) noexcept
 Return a function_ptr<ErasedPrototype> by from an input Callable, without dynamically allocating memory. Note that the size of function ptr returned will be exactly the amount to store the callable, which may not be the default size of function_ptr<ErasedPrototype>.
 

Detailed Description

The namespace for the function pointer type.

Function Documentation

◆ emplace_function_ptr()

template<class ErasedPrototype , class Callable , size_t callable_storage_bytes = default_callable_storage_bytes, class... CallableConstructionArgs>
constexpr function_ptr< ErasedPrototype, callable_storage_bytes > quickcpplib::_xxx::function_ptr::emplace_function_ptr ( CallableConstructionArgs &&...  args)
inlineconstexpr

Return a function_ptr<ErasedPrototype> by emplacing Callable(CallableConstructionArgs...). If Callable is nothrow move constructible and sufficiently small, avoids dynamic memory allocation.

292 {
293 return function_ptr<ErasedPrototype, callable_storage_bytes>(typename function_ptr<ErasedPrototype, callable_storage_bytes>::template _emplace_t<Callable>(), static_cast<CallableConstructionArgs &&>(args)...);
294 }
A move only lightweight std::function alternative, with configurable small object optimisation.
Definition function_ptr.hpp:49

◆ emplace_function_ptr_nothrow()

template<class ErasedPrototype , class Callable , class... CallableConstructionArgs>
constexpr function_ptr< ErasedPrototype,(sizeof(Callable)+sizeof(void *)+sizeof(void *) - 1) &~(sizeof(void *) - 1)> quickcpplib::_xxx::function_ptr::emplace_function_ptr_nothrow ( CallableConstructionArgs &&...  args)
inlineconstexprnoexcept

Return a function_ptr<ErasedPrototype> by emplacing Callable(CallableConstructionArgs...), without dynamically allocating memory. Note that the size of function ptr returned will be exactly the amount to store the callable, which may not be the default size of function_ptr<ErasedPrototype>.

302 {
303 using type = function_ptr<ErasedPrototype, (sizeof(Callable) + sizeof(void *) + sizeof(void *) - 1) & ~(sizeof(void *) - 1)>;
304 static_assert(type::template is_ssoable<Callable>, "The specified callable is not SSOable (probably lacks nothrow move construction)");
305 return type(typename type::template _emplace_t<Callable>(), static_cast<CallableConstructionArgs &&>(args)...);
306 }

◆ make_function_ptr()

template<class ErasedPrototype , class Callable , size_t callable_storage_bytes = default_callable_storage_bytes>
constexpr function_ptr< ErasedPrototype, callable_storage_bytes > quickcpplib::_xxx::function_ptr::make_function_ptr ( Callable &&  f)
inlineconstexpr

Return a function_ptr<ErasedPrototype> by from an input Callable. If Callable is nothrow move constructible and sufficiently small, avoids dynamic memory allocation.

314 {
315 return emplace_function_ptr<ErasedPrototype, std::decay_t<Callable>, callable_storage_bytes>(static_cast<Callable &&>(f));
316 }

◆ make_function_ptr_nothrow()

template<class ErasedPrototype , class Callable >
constexpr auto quickcpplib::_xxx::function_ptr::make_function_ptr_nothrow ( Callable &&  f)
inlineconstexprnoexcept

Return a function_ptr<ErasedPrototype> by from an input Callable, without dynamically allocating memory. Note that the size of function ptr returned will be exactly the amount to store the callable, which may not be the default size of function_ptr<ErasedPrototype>.

324 {
325 return emplace_function_ptr_nothrow<ErasedPrototype, std::decay_t<Callable>>(static_cast<Callable &&>(f));
326 }