JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::dsp::FixedSizeFunction< len, Ret(Args...)> Class Template Reference

A type similar to std::function that holds a callable object. More...

#include <juce_FixedSizeFunction.h>

Collaboration diagram for juce::dsp::FixedSizeFunction< len, Ret(Args...)>:

Public Member Functions

 FixedSizeFunction () noexcept=default
 Create an empty function. More...
 
template<typename Callable , typename Fn = Decay<Callable>, IntIfValidConversion< Callable > = 0>
 FixedSizeFunction (Callable &&callable)
 Forwards the passed Callable into the internal storage buffer. More...
 
 FixedSizeFunction (const FixedSizeFunction &)=delete
 
 FixedSizeFunction (FixedSizeFunction &&other) noexcept
 Move constructor. More...
 
template<size_t otherLen, typename std::enable_if<(otherLen< len), int >::type = 0>
 FixedSizeFunction (FixedSizeFunction< otherLen, Ret(Args...)> &&other) noexcept
 Converting constructor from smaller FixedSizeFunctions. More...
 
 FixedSizeFunction (std::nullptr_t) noexcept
 Create an empty function. More...
 
 ~FixedSizeFunction () noexcept
 Destructor. More...
 
 operator bool () const noexcept
 Returns true if this instance currently holds a callable. More...
 
Ret operator() (Args... args) const
 If this instance is currently storing a callable object, calls that object, otherwise throws std::bad_function_call. More...
 
template<typename Callable , IntIfValidConversion< Callable > = 0>
FixedSizeFunctionoperator= (Callable &&callable)
 Assigns a new callable to this instance. More...
 
FixedSizeFunctionoperator= (const FixedSizeFunction &)=delete
 
FixedSizeFunctionoperator= (FixedSizeFunction &&other) noexcept
 Move assignment operator. More...
 
template<size_t otherLen, typename std::enable_if<(otherLen< len), int >::type = 0>
FixedSizeFunctionoperator= (FixedSizeFunction< otherLen, Ret(Args...)> &&other) noexcept
 Move assignment from smaller FixedSizeFunctions. More...
 
FixedSizeFunctionoperator= (std::nullptr_t) noexcept
 Nulls this instance. More...
 

Private Types

template<typename Item >
using Decay = typename std::decay< Item >::type
 
template<typename Item , typename Fn = Decay<Item>>
using IntIfValidConversion = typename std::enable_if< sizeof(Fn)<=len &&alignof(Fn)<=alignof(Storage) &&! std::is_same< FixedSizeFunction, Fn >::value, int >::type
 
using Storage = typename std::aligned_storage< len >::type
 

Private Member Functions

void clear () noexcept
 
template<size_t otherLen, typename T >
void move (FixedSizeFunction< otherLen, T > &&other) noexcept
 

Private Attributes

Storage storage
 
const detail::Vtable< Ret, Args... > * vtable = nullptr
 

Friends

template<size_t , typename >
class FixedSizeFunction
 

Detailed Description

template<size_t len, typename Ret, typename... Args>
class juce::dsp::FixedSizeFunction< len, Ret(Args...)>

A type similar to std::function that holds a callable object.

Unlike std::function, the callable object will always be stored in a buffer of size len that is internal to the FixedSizeFunction instance. This in turn means that creating a FixedSizeFunction instance will never allocate, making FixedSizeFunctions suitable for use in realtime contexts.

@tags{DSP}

Member Typedef Documentation

◆ Decay

template<size_t len, typename Ret , typename... Args>
template<typename Item >
using juce::dsp::FixedSizeFunction< len, Ret(Args...)>::Decay = typename std::decay<Item>::type
private

◆ IntIfValidConversion

template<size_t len, typename Ret , typename... Args>
template<typename Item , typename Fn = Decay<Item>>
using juce::dsp::FixedSizeFunction< len, Ret(Args...)>::IntIfValidConversion = typename std::enable_if<sizeof (Fn) <= len && alignof (Fn) <= alignof (Storage) && ! std::is_same<FixedSizeFunction, Fn>::value, int>::type
private

◆ Storage

template<size_t len, typename Ret , typename... Args>
using juce::dsp::FixedSizeFunction< len, Ret(Args...)>::Storage = typename std::aligned_storage<len>::type
private

Constructor & Destructor Documentation

◆ FixedSizeFunction() [1/6]

template<size_t len, typename Ret , typename... Args>
juce::dsp::FixedSizeFunction< len, Ret(Args...)>::FixedSizeFunction ( )
defaultnoexcept

Create an empty function.

◆ FixedSizeFunction() [2/6]

template<size_t len, typename Ret , typename... Args>
juce::dsp::FixedSizeFunction< len, Ret(Args...)>::FixedSizeFunction ( std::nullptr_t  )
inlinenoexcept

Create an empty function.

◆ FixedSizeFunction() [3/6]

template<size_t len, typename Ret , typename... Args>
juce::dsp::FixedSizeFunction< len, Ret(Args...)>::FixedSizeFunction ( const FixedSizeFunction< len, Ret(Args...)> &  )
delete

◆ FixedSizeFunction() [4/6]

template<size_t len, typename Ret , typename... Args>
template<typename Callable , typename Fn = Decay<Callable>, IntIfValidConversion< Callable > = 0>
juce::dsp::FixedSizeFunction< len, Ret(Args...)>::FixedSizeFunction ( Callable &&  callable)
inline

Forwards the passed Callable into the internal storage buffer.

References jassertquiet, and juce::gl::len.

◆ FixedSizeFunction() [5/6]

template<size_t len, typename Ret , typename... Args>
juce::dsp::FixedSizeFunction< len, Ret(Args...)>::FixedSizeFunction ( FixedSizeFunction< len, Ret(Args...)> &&  other)
inlinenoexcept

Move constructor.

◆ FixedSizeFunction() [6/6]

template<size_t len, typename Ret , typename... Args>
template<size_t otherLen, typename std::enable_if<(otherLen< len), int >::type = 0>
juce::dsp::FixedSizeFunction< len, Ret(Args...)>::FixedSizeFunction ( FixedSizeFunction< otherLen, Ret(Args...)> &&  other)
inlinenoexcept

Converting constructor from smaller FixedSizeFunctions.

◆ ~FixedSizeFunction()

template<size_t len, typename Ret , typename... Args>
juce::dsp::FixedSizeFunction< len, Ret(Args...)>::~FixedSizeFunction ( )
inlinenoexcept

Destructor.

Member Function Documentation

◆ clear()

template<size_t len, typename Ret , typename... Args>
void juce::dsp::FixedSizeFunction< len, Ret(Args...)>::clear ( )
inlineprivatenoexcept

◆ move()

template<size_t len, typename Ret , typename... Args>
template<size_t otherLen, typename T >
void juce::dsp::FixedSizeFunction< len, Ret(Args...)>::move ( FixedSizeFunction< otherLen, T > &&  other)
inlineprivatenoexcept

◆ operator bool()

template<size_t len, typename Ret , typename... Args>
juce::dsp::FixedSizeFunction< len, Ret(Args...)>::operator bool ( ) const
inlineexplicitnoexcept

Returns true if this instance currently holds a callable.

◆ operator()()

template<size_t len, typename Ret , typename... Args>
Ret juce::dsp::FixedSizeFunction< len, Ret(Args...)>::operator() ( Args...  args) const
inline

If this instance is currently storing a callable object, calls that object, otherwise throws std::bad_function_call.

◆ operator=() [1/5]

template<size_t len, typename Ret , typename... Args>
template<typename Callable , IntIfValidConversion< Callable > = 0>
FixedSizeFunction& juce::dsp::FixedSizeFunction< len, Ret(Args...)>::operator= ( Callable &&  callable)
inline

Assigns a new callable to this instance.

◆ operator=() [2/5]

template<size_t len, typename Ret , typename... Args>
FixedSizeFunction& juce::dsp::FixedSizeFunction< len, Ret(Args...)>::operator= ( const FixedSizeFunction< len, Ret(Args...)> &  )
delete

◆ operator=() [3/5]

template<size_t len, typename Ret , typename... Args>
FixedSizeFunction& juce::dsp::FixedSizeFunction< len, Ret(Args...)>::operator= ( FixedSizeFunction< len, Ret(Args...)> &&  other)
inlinenoexcept

Move assignment operator.

◆ operator=() [4/5]

template<size_t len, typename Ret , typename... Args>
template<size_t otherLen, typename std::enable_if<(otherLen< len), int >::type = 0>
FixedSizeFunction& juce::dsp::FixedSizeFunction< len, Ret(Args...)>::operator= ( FixedSizeFunction< otherLen, Ret(Args...)> &&  other)
inlinenoexcept

Move assignment from smaller FixedSizeFunctions.

◆ operator=() [5/5]

template<size_t len, typename Ret , typename... Args>
FixedSizeFunction& juce::dsp::FixedSizeFunction< len, Ret(Args...)>::operator= ( std::nullptr_t  )
inlinenoexcept

Nulls this instance.

Friends And Related Function Documentation

◆ FixedSizeFunction

template<size_t len, typename Ret , typename... Args>
template<size_t , typename >
friend class FixedSizeFunction
friend

Member Data Documentation

◆ storage

template<size_t len, typename Ret , typename... Args>
Storage juce::dsp::FixedSizeFunction< len, Ret(Args...)>::storage
mutableprivate

◆ vtable

template<size_t len, typename Ret , typename... Args>
const detail::Vtable<Ret, Args...>* juce::dsp::FixedSizeFunction< len, Ret(Args...)>::vtable = nullptr
private

The documentation for this class was generated from the following file: