|
|
Boost.dynamic_anyHeader < boost/dynamic_any/function.hpp> |
functionfunction synopsis
function
Signature is a function type used to designate the result and the arguments of the template class
function. There are four special anyT-based types: anyT,
const anyT, anyT& and const anyT&.
They are used to indicate that the argument or the result has type any<OperationList>
or a reference to any<OperationList> (possibly const-qualified). Template argument
OperationList is deduced from actual arguments of the function call operator.
Therefore, Signature must have at least one anyT-based argument.
[Example: Signature const anyT(int,anyT&) is resolved as
const any<OperationList>(int,any<OperationList>&)
during a function call. ]
function synopsisnamespace boost { namespace dynamic_any { class anyT {}; template<class EndFunction, class Signature> class function { public: typedef Signature signature; static const std::size_t arity = function_traits<Signature>::arity; template<class OperationList> result operator()(Arg1,...,ArgN) const; template<class OperationList> result no_call(Arg1,...,ArgN) const { throw bad_function_call(); } template<class T, class OperationList> result call_ex(Arg1 a1,...,ArgM aM) const { return static_cast<const EndFunction*>(this)->call(a1,...,aK); } }; } } // namespace boost { namespace dynamic_any {
Template class function should never been used directly.
Instead, a user-defined function must be derived from it. Template agrument
EndFunction
[Example:
class sizeof_ : public function<
sizeof_, // curiously recurring template pattern
std::size_t (const anyT&)
>
{
public:
template<class T> std::size_t call(const T&) const
{
return sizeof(T);
}
};
--end example. ]
function functionstemplate<class OperationList> result operator()(Arg1,...,ArgN) const;
template<class OperationList> result no_call(Arg1,...,ArgN) const;
template<class T, class OperationList> result call_ex(Arg1 a1,...,ArgM aM) const;
{{function}}
{{Example(s)}}
Revised 05 November, 2001
© Copyright Alexander Nasonov 2002-2003. All Rights Reserved.