Roy Want / Mbed OS beaconCompileReadyFork
Embed: (wiki syntax)

« Back to documentation index

Thunk Class Reference

Thunk Class Reference

A Thunk is a container holding any kind of nullary callable. More...

#include <Thunk.h>

Public Member Functions

 Thunk ()
 Thunk Empty constructor.
template<typename F >
 Thunk (const F &f)
 Construct a Thunk from a nullary callable of type F.
 Thunk (void(*f)())
 Special constructor for pointer to function.
 Thunk (const Thunk &other)
 Copy construction of a thunk.
 ~Thunk ()
 Destruction of the Thunk correctly call the destructor of the inner callable.
Thunkoperator= (const Thunk &other)
 Copy assignement from another thunk.
void operator() () const
 Call operator.

Detailed Description

A Thunk is a container holding any kind of nullary callable.

It wrap value semantic and function call operations of the inner callable held.

Note:
Thunk of callable bound to arguments should be generated by the function make_thunk.

Definition at line 38 of file Thunk.h.


Constructor & Destructor Documentation

Thunk (  )

Thunk Empty constructor.

Thunk empty constructor Implementation.

When this thunk is called, if does nothing.

Due to the way templates and forwarding work in C++, it was not possible to provide this implementation in Thunk.h

Definition at line 56 of file Thunk.impl.h.

Thunk ( const F &  f )

Construct a Thunk from a nullary callable of type F.

Thunk constructor Implementation.

When the call operator is invoked, it call a copy of f ( f() ).

Due to the way templates and forwarding work in C++, it was not possible to provide this implementation in Thunk.h

Definition at line 31 of file Thunk.impl.h.

Thunk ( void(*)()  f )

Special constructor for pointer to function.

Specialization for function pointers.

Allow references to functions to gracefully decay into pointer to function. Otherwise, reference to function are not copy constructible (their is no constructible function type in C++). When the call operator is invoked, it call a copy of f ( f() ).

This overload will be chosen when the tyope in input is a reference to a function.

Parameters:
fThe function to transform in Thunk.

Definition at line 43 of file Thunk.impl.h.

Thunk ( const Thunk other )

Copy construction of a thunk.

Take care that the inner F is correctly copied.

Definition at line 73 of file Thunk.h.

~Thunk (  )

Destruction of the Thunk correctly call the destructor of the inner callable.

Definition at line 81 of file Thunk.h.


Member Function Documentation

void operator() (  ) const

Call operator.

Invoke the inner callable.

Definition at line 102 of file Thunk.h.

Thunk& operator= ( const Thunk other )

Copy assignement from another thunk.

Ensure that the callable held is correctly destroyed then copy the correctly copy the new one.

Definition at line 90 of file Thunk.h.