mirror of
https://github.com/boostorg/compose.git
synced 2026-01-19 04:02:16 +00:00
460 lines
32 KiB
HTML
460 lines
32 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>compose.hpp</TITLE>
|
|
</HEAD>
|
|
|
|
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
|
|
|
|
<TABLE HEIGHT=40 WIDTH="100%">
|
|
<TR> <TD ALIGN=LEFT WIDTH="100%" BGCOLOR="#DDDDDD">
|
|
<FONT face="Arial,Helvetica" size=+2><B>
|
|
compose.hpp
|
|
</B></FONT>
|
|
</TD></TR></TABLE><BR>
|
|
|
|
<FONT face="Arial,Helvetica"><B>
|
|
The following code example is taken from the book<BR>
|
|
<A HREF="http://www.josuttis.com/libbook/" TARGET="_top">
|
|
The C++ Standard Library - A Tutorial and Reference</A><BR>
|
|
by Nicolai M. Josuttis, Addison-Wesley, 1999<BR>
|
|
<A HREF="http://www.josuttis.com/libbook/copyright.html">
|
|
© Copyright</A> Nicolai M. Josuttis 1999<BR>
|
|
</B></FONT>
|
|
|
|
<BR><BR><TT>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* supplementing compose function objects</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* Son Dez 26 22:11:12 MET 1999</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
#ifndef BOOST_COMPOSE_HPP<BR>
|
|
#define BOOST_COMPOSE_HPP<BR>
|
|
<BR>
|
|
#include <functional><BR>
|
|
<BR>
|
|
namespace boost {<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>**********************************************************</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* type nullary_function</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* - as supplement to unary_function and binary_function</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>**********************************************************/</I></FONT><BR>
|
|
template <class Result><BR>
|
|
struct nullary_function {<BR>
|
|
typedef Result result_type;<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>**********************************************************</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* ptr_fun for functions with no argument</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>**********************************************************/</I></FONT><BR>
|
|
template <class Result><BR>
|
|
class pointer_to_nullary_function : public nullary_function<Result><BR>
|
|
{<BR>
|
|
protected:<BR>
|
|
Result (*ptr)();<BR>
|
|
public:<BR>
|
|
pointer_to_nullary_function() {<BR>
|
|
}<BR>
|
|
explicit pointer_to_nullary_function(Result (*x)()) : ptr(x) {<BR>
|
|
}<BR>
|
|
Result operator()() const { <BR>
|
|
return ptr();<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
template <class Result><BR>
|
|
inline pointer_to_nullary_function<Result> ptr_fun(Result (*x)())<BR>
|
|
{<BR>
|
|
return pointer_to_nullary_function<Result>(x);<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*********** compose_f_gx_t and compose_f_gx **********************/</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* class for the compose_f_gx adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
class compose_f_gx_t<BR>
|
|
: public std::unary_function<typename OP2::argument_type,<BR>
|
|
typename OP1::result_type><BR>
|
|
{<BR>
|
|
private:<BR>
|
|
OP1 op1; <I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// process: op1(op2(x))</I></FONT><BR>
|
|
OP2 op2;<BR>
|
|
public:<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// constructor</I></FONT><BR>
|
|
compose_f_gx_t(const OP1& o1, const OP2& o2)<BR>
|
|
: op1(o1), op2(o2) {<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// function call</I></FONT><BR>
|
|
typename OP1::result_type<BR>
|
|
operator()(const typename OP2::argument_type& x) const {<BR>
|
|
return op1(op2(x));<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* convenience functions for the compose_f_gx adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
inline compose_f_gx_t<OP1,OP2><BR>
|
|
compose_f_gx (const OP1& o1, const OP2& o2) {<BR>
|
|
return compose_f_gx_t<OP1,OP2>(o1,o2);<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*********** compose_f_gx_hx_t and compose_f_gx_hx **********************/</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* class for the compose_f_gx_hx adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2, class OP3><BR>
|
|
class compose_f_gx_hx_t<BR>
|
|
: public std::unary_function<typename OP2::argument_type,<BR>
|
|
typename OP1::result_type><BR>
|
|
{<BR>
|
|
private:<BR>
|
|
OP1 op1; <I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// process: op1(op2(x),op3(x))</I></FONT><BR>
|
|
OP2 op2;<BR>
|
|
OP3 op3;<BR>
|
|
public:<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// constructor</I></FONT><BR>
|
|
compose_f_gx_hx_t (const OP1& o1, const OP2& o2, const OP3& o3)<BR>
|
|
: op1(o1), op2(o2), op3(o3) {<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// function call</I></FONT><BR>
|
|
typename OP1::result_type<BR>
|
|
operator()(const typename OP2::argument_type& x) const {<BR>
|
|
return op1(op2(x),op3(x));<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* convenience functions for the compose_f_gx_hx adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2, class OP3><BR>
|
|
inline compose_f_gx_hx_t<OP1,OP2,OP3><BR>
|
|
compose_f_gx_hx (const OP1& o1, const OP2& o2, const OP3& o3) {<BR>
|
|
return compose_f_gx_hx_t<OP1,OP2,OP3>(o1,o2,o3);<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*********** compose_f_gxy_t and compose_f_gxy **********************/</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* class for the compose_f_gxy adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
class compose_f_gxy_t<BR>
|
|
: public std::binary_function<typename OP2::first_argument_type,<BR>
|
|
typename OP2::second_argument_type,<BR>
|
|
typename OP1::result_type><BR>
|
|
{<BR>
|
|
private:<BR>
|
|
OP1 op1; <I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// process: op1(op2(x,y))</I></FONT><BR>
|
|
OP2 op2;<BR>
|
|
public:<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// constructor</I></FONT><BR>
|
|
compose_f_gxy_t (const OP1& o1, const OP2& o2)<BR>
|
|
: op1(o1), op2(o2) {<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// function call</I></FONT><BR>
|
|
typename OP1::result_type<BR>
|
|
operator()(const typename OP2::first_argument_type& x,<BR>
|
|
const typename OP2::second_argument_type& y) const {<BR>
|
|
return op1(op2(x,y));<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* convenience function for the compose_f_gxy adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
inline compose_f_gxy_t<OP1,OP2><BR>
|
|
compose_f_gxy (const OP1& o1, const OP2& o2) {<BR>
|
|
return compose_f_gxy_t<OP1,OP2>(o1,o2);<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*********** compose_f_gx_hy_t and compose_f_gx_hy **********************/</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* class for the compose_f_gx_hy adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2, class OP3><BR>
|
|
class compose_f_gx_hy_t<BR>
|
|
: public std::binary_function<typename OP2::argument_type,<BR>
|
|
typename OP3::argument_type,<BR>
|
|
typename OP1::result_type><BR>
|
|
{<BR>
|
|
private:<BR>
|
|
OP1 op1; <I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// process: op1(op2(x),op3(y))</I></FONT><BR>
|
|
OP2 op2;<BR>
|
|
OP3 op3;<BR>
|
|
public:<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// constructor</I></FONT><BR>
|
|
compose_f_gx_hy_t (const OP1& o1, const OP2& o2, const OP3& o3)<BR>
|
|
: op1(o1), op2(o2), op3(o3) {<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// function call</I></FONT><BR>
|
|
typename OP1::result_type<BR>
|
|
operator()(const typename OP2::argument_type& x,<BR>
|
|
const typename OP3::argument_type& y) const {<BR>
|
|
return op1(op2(x),op3(y));<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* convenience function for the compose_f_gx_hy adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2, class OP3><BR>
|
|
inline compose_f_gx_hy_t<OP1,OP2,OP3><BR>
|
|
compose_f_gx_hy (const OP1& o1, const OP2& o2, const OP3& o3) {<BR>
|
|
return compose_f_gx_hy_t<OP1,OP2,OP3>(o1,o2,o3);<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*********** compose_f_g_t and compose_f_g **********************/</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* class for the compose_f_g adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
class compose_f_g_t<BR>
|
|
: public boost::nullary_function<typename OP1::result_type><BR>
|
|
{<BR>
|
|
private:<BR>
|
|
OP1 op1; <I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// process: op1(op2())</I></FONT><BR>
|
|
OP2 op2;<BR>
|
|
public:<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// constructor</I></FONT><BR>
|
|
compose_f_g_t(const OP1& o1, const OP2& o2)<BR>
|
|
: op1(o1), op2(o2) {<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// function call</I></FONT><BR>
|
|
typename OP1::result_type<BR>
|
|
operator()() const {<BR>
|
|
return op1(op2());<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* convenience functions for the compose_f_g adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
inline compose_f_g_t<OP1,OP2><BR>
|
|
compose_f_g (const OP1& o1, const OP2& o2) {<BR>
|
|
return compose_f_g_t<OP1,OP2>(o1,o2);<BR>
|
|
}<BR>
|
|
<BR>
|
|
} <I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* namespace boost */</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
#endif <I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*BOOST_COMPOSE_HPP*/</I></FONT></I></FONT><BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* supplementing compose function objects</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* Son Dez 26 22:14:55 MET 1999</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
#ifndef BOOST_COMPOSE_HPP<BR>
|
|
#define BOOST_COMPOSE_HPP<BR>
|
|
<BR>
|
|
#include <functional><BR>
|
|
<BR>
|
|
namespace boost {<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>**********************************************************</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* type nullary_function</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* - as supplement to unary_function and binary_function</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>**********************************************************/</I></FONT><BR>
|
|
template <class Result><BR>
|
|
struct nullary_function {<BR>
|
|
typedef Result result_type;<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>**********************************************************</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* ptr_fun for functions with no argument</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>**********************************************************/</I></FONT><BR>
|
|
template <class Result><BR>
|
|
class pointer_to_nullary_function : public nullary_function<Result><BR>
|
|
{<BR>
|
|
protected:<BR>
|
|
Result (*ptr)();<BR>
|
|
public:<BR>
|
|
pointer_to_nullary_function() {<BR>
|
|
}<BR>
|
|
explicit pointer_to_nullary_function(Result (*x)()) : ptr(x) {<BR>
|
|
}<BR>
|
|
Result operator()() const { <BR>
|
|
return ptr();<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
template <class Result><BR>
|
|
inline pointer_to_nullary_function<Result> ptr_fun(Result (*x)())<BR>
|
|
{<BR>
|
|
return pointer_to_nullary_function<Result>(x);<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*********** compose_f_gx_t and compose_f_gx **********************/</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* class for the compose_f_gx adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
class compose_f_gx_t<BR>
|
|
: public std::unary_function<typename OP2::argument_type,<BR>
|
|
typename OP1::result_type><BR>
|
|
{<BR>
|
|
private:<BR>
|
|
OP1 op1; <I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// process: op1(op2(x))</I></FONT><BR>
|
|
OP2 op2;<BR>
|
|
public:<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// constructor</I></FONT><BR>
|
|
compose_f_gx_t(const OP1& o1, const OP2& o2)<BR>
|
|
: op1(o1), op2(o2) {<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// function call</I></FONT><BR>
|
|
typename OP1::result_type<BR>
|
|
operator()(const typename OP2::argument_type& x) const {<BR>
|
|
return op1(op2(x));<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* convenience functions for the compose_f_gx adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
inline compose_f_gx_t<OP1,OP2><BR>
|
|
compose_f_gx (const OP1& o1, const OP2& o2) {<BR>
|
|
return compose_f_gx_t<OP1,OP2>(o1,o2);<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*********** compose_f_gx_hx_t and compose_f_gx_hx **********************/</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* class for the compose_f_gx_hx adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2, class OP3><BR>
|
|
class compose_f_gx_hx_t<BR>
|
|
: public std::unary_function<typename OP2::argument_type,<BR>
|
|
typename OP1::result_type><BR>
|
|
{<BR>
|
|
private:<BR>
|
|
OP1 op1; <I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// process: op1(op2(x),op3(x))</I></FONT><BR>
|
|
OP2 op2;<BR>
|
|
OP3 op3;<BR>
|
|
public:<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// constructor</I></FONT><BR>
|
|
compose_f_gx_hx_t (const OP1& o1, const OP2& o2, const OP3& o3)<BR>
|
|
: op1(o1), op2(o2), op3(o3) {<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// function call</I></FONT><BR>
|
|
typename OP1::result_type<BR>
|
|
operator()(const typename OP2::argument_type& x) const {<BR>
|
|
return op1(op2(x),op3(x));<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* convenience functions for the compose_f_gx_hx adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2, class OP3><BR>
|
|
inline compose_f_gx_hx_t<OP1,OP2,OP3><BR>
|
|
compose_f_gx_hx (const OP1& o1, const OP2& o2, const OP3& o3) {<BR>
|
|
return compose_f_gx_hx_t<OP1,OP2,OP3>(o1,o2,o3);<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*********** compose_f_gxy_t and compose_f_gxy **********************/</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* class for the compose_f_gxy adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
class compose_f_gxy_t<BR>
|
|
: public std::binary_function<typename OP2::first_argument_type,<BR>
|
|
typename OP2::second_argument_type,<BR>
|
|
typename OP1::result_type><BR>
|
|
{<BR>
|
|
private:<BR>
|
|
OP1 op1; <I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// process: op1(op2(x,y))</I></FONT><BR>
|
|
OP2 op2;<BR>
|
|
public:<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// constructor</I></FONT><BR>
|
|
compose_f_gxy_t (const OP1& o1, const OP2& o2)<BR>
|
|
: op1(o1), op2(o2) {<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// function call</I></FONT><BR>
|
|
typename OP1::result_type<BR>
|
|
operator()(const typename OP2::first_argument_type& x,<BR>
|
|
const typename OP2::second_argument_type& y) const {<BR>
|
|
return op1(op2(x,y));<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* convenience function for the compose_f_gxy adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
inline compose_f_gxy_t<OP1,OP2><BR>
|
|
compose_f_gxy (const OP1& o1, const OP2& o2) {<BR>
|
|
return compose_f_gxy_t<OP1,OP2>(o1,o2);<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*********** compose_f_gx_hy_t and compose_f_gx_hy **********************/</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* class for the compose_f_gx_hy adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2, class OP3><BR>
|
|
class compose_f_gx_hy_t<BR>
|
|
: public std::binary_function<typename OP2::argument_type,<BR>
|
|
typename OP3::argument_type,<BR>
|
|
typename OP1::result_type><BR>
|
|
{<BR>
|
|
private:<BR>
|
|
OP1 op1; <I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// process: op1(op2(x),op3(y))</I></FONT><BR>
|
|
OP2 op2;<BR>
|
|
OP3 op3;<BR>
|
|
public:<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// constructor</I></FONT><BR>
|
|
compose_f_gx_hy_t (const OP1& o1, const OP2& o2, const OP3& o3)<BR>
|
|
: op1(o1), op2(o2), op3(o3) {<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// function call</I></FONT><BR>
|
|
typename OP1::result_type<BR>
|
|
operator()(const typename OP2::argument_type& x,<BR>
|
|
const typename OP3::argument_type& y) const {<BR>
|
|
return op1(op2(x),op3(y));<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* convenience function for the compose_f_gx_hy adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2, class OP3><BR>
|
|
inline compose_f_gx_hy_t<OP1,OP2,OP3><BR>
|
|
compose_f_gx_hy (const OP1& o1, const OP2& o2, const OP3& o3) {<BR>
|
|
return compose_f_gx_hy_t<OP1,OP2,OP3>(o1,o2,o3);<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*********** compose_f_g_t and compose_f_g **********************/</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* class for the compose_f_g adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
class compose_f_g_t<BR>
|
|
: public boost::nullary_function<typename OP1::result_type><BR>
|
|
{<BR>
|
|
private:<BR>
|
|
OP1 op1; <I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// process: op1(op2())</I></FONT><BR>
|
|
OP2 op2;<BR>
|
|
public:<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// constructor</I></FONT><BR>
|
|
compose_f_g_t(const OP1& o1, const OP2& o2)<BR>
|
|
: op1(o1), op2(o2) {<BR>
|
|
}<BR>
|
|
<BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>// function call</I></FONT><BR>
|
|
typename OP1::result_type<BR>
|
|
operator()() const {<BR>
|
|
return op1(op2());<BR>
|
|
}<BR>
|
|
};<BR>
|
|
<BR>
|
|
<Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* convenience functions for the compose_f_g adapter</I></FONT><BR>
|
|
<I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*/</I></FONT><BR>
|
|
template <class OP1, class OP2><BR>
|
|
inline compose_f_g_t<OP1,OP2><BR>
|
|
compose_f_g (const OP1& o1, const OP2& o2) {<BR>
|
|
return compose_f_g_t<OP1,OP2>(o1,o2);<BR>
|
|
}<BR>
|
|
<BR>
|
|
} <I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>* namespace boost */</I></FONT></I></FONT><BR>
|
|
<BR>
|
|
#endif <I><FONT face="Arial,Helvetica" color="0000FF" size=-1><Font color="0000FF" >/</FONT><I><FONT face="Arial,Helvetica" color="0000FF" size=-1>*BOOST_COMPOSE_HPP*/</I></FONT></I></FONT><BR>
|
|
</TT>
|
|
</BODY>
|
|
</HTML>
|