function


An os_function is a generic function pointer class which can be specified with up to ten template parameters. The first template argument specifies the class which the function is a member of. If the function is not a member of any class or is a static member, then os_no_member should be used. The second template argument specifies the return type. The remaining template arguments are optional. An os_function can encapsulate functions, static methods, regular methods, or constant methods. If the function operator is invoked on an os_function before its function pointer is set, then an exception will be thown.

Use of multiple template partial specialization gives the flexibility of having a variable length argument list. Therefore, the compiler must be able to support multiple template partial specialization and OS_NO_PARTIAL_SPECIALIZATION must NOT be defined to use this class.

Library

Helper<ToolKit>

Declaration

#include <ospace/helper/genfunc.h>

template< class T, class R, ... >
class os_function

Interface

Constructor
os_function( R (*function)(...) )
Constructs a function pointer referencing function as the function/static method to be invoked.
Constructor
os_function( T* object , R (*method)(...) )
Constructs a function pointer referencing method as the method to be invoked on the target object .
Constructor
os_function( T* object , R (*cmethod)(...) const )
Constructs a function pointer referencing method as the const method to be invoked on the target object .
Constructor
os_function( const os_function< T, R, ... >& original )
Constructs a function pointer referencing the function/method and the target of original .
Destructor
~os_function()
Destroys the function pointer.
=
os_function< T, R, ... >& operator=( const os_function< T, R, ... >& original )
Assigns function pointer from original .
=
os_function< T, R, ... >& operator=( int zero )
Clears the function pointer if zero is 0 .
()
R operator()( ... ) const
Returns the result of the invocation executed by this function pointer. If the function pointer is empty, then an exception is thrown.

Throws: os_helper_toolkit_error

clear
void clear()
Sets the target and the function/method to 0 .
empty
bool empty() const
Returns true if the function/method referenced by this function pointer is valid.

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.