123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- #pragma once
- //-----------------------------------------------------------------------------
- // fcn_obj
- //-----------------------------------------------------------------------------
- template <class stype, class vtype>
- class fcn_obj
- {
- public:
- fcn_obj (stype & (*f) (stype &, vtype), vtype v):
- func (f), val (v)
- {
- }
- stype & operator () (stype & s) const
- {
- return (*func) (s, val);
- }
- private:
- stype & (*func) (stype &, vtype);
- vtype val;
- };
- template <class stype, class vtype>
- stype & operator << (stype & ofile, const fcn_obj <stype, vtype> (im))
- {
- return im (ofile);
- }
- template <class stype, class vtype>
- stype & operator >> (stype & ifile, const fcn_obj <stype, vtype> (im))
- {
- return im (ifile);
- }
- //-----------------------------------------------------------------------------
- // fcn_2obj
- //-----------------------------------------------------------------------------
- template <class stype, class vtype1, class vtype2>
- class fcn_2obj
- {
- public:
- fcn_2obj (stype & (*f) (stype &, vtype1, vtype2), vtype1 v1, vtype2 v2):
- func (f), val1 (v1), val2 (v2)
- {
- }
- stype & operator () (stype & s) const
- {
- return (*func) (s, val1, val2);
- }
- private:
- stype & (*func) (stype &, vtype1, vtype2);
- vtype1 val1;
- vtype2 val2;
- };
- template <class stype, class vtype1, class vtype2>
- stype & operator << (stype & ofile, const fcn_2obj <stype, vtype1, vtype2> (im))
- {
- return im (ofile);
- }
- template <class stype, class vtype1, class vtype2>
- stype & operator >> (stype & ifile, const fcn_2obj <stype, vtype1, vtype2> (im))
- {
- return im (ifile);
- }
- //-----------------------------------------------------------------------------
- // fcn_3obj
- //-----------------------------------------------------------------------------
- template <class stype, class vtype1, class vtype2, class vtype3>
- class fcn_3obj
- {
- public:
- fcn_3obj (stype & (*f) (stype &, vtype1, vtype2, vtype3), vtype1 v1, vtype2 v2, vtype3 v3):
- func (f), val1 (v1), val2 (v2), val3 (v3)
- {
- }
- stype & operator () (stype & s) const
- {
- return (*func) (s, val1, val2, val3);
- }
- private:
- stype & (*func) (stype &, vtype1, vtype2, vtype3);
- vtype1 val1;
- vtype2 val2;
- vtype3 val3;
- };
- template <class stype, class vtype1, class vtype2, class vtype3>
- stype & operator << (stype & ofile, const fcn_3obj <stype, vtype1, vtype2, vtype3> (im))
- {
- return im (ofile);
- }
- template <class stype, class vtype1, class vtype2, class vtype3>
- stype & operator >> (stype & ifile, const fcn_3obj <stype, vtype1, vtype2, vtype3> (im))
- {
- return im (ifile);
- }
- //-----------------------------------------------------------------------------
- // fcn_4obj
- //-----------------------------------------------------------------------------
- template <class stype, class vtype1, class vtype2, class vtype3, class vtype4>
- class fcn_4obj
- {
- public:
- fcn_4obj (stype & (*f) (stype &, vtype1, vtype2, vtype3, vtype4), vtype1 v1, vtype2 v2, vtype3 v3, vtype4 v4) :
- func (f), val1 (v1), val2 (v2), val3 (v3), val4 (v4)
- {
- }
- stype & operator () (stype & s) const
- {
- return (*func) (s, val1, val2, val3, val4);
- }
- private:
- stype & (*func) (stype &, vtype1, vtype2, vtype3, vtype4);
- vtype1 val1;
- vtype2 val2;
- vtype3 val3;
- vtype4 val4;
- };
- template <class stype, class vtype1, class vtype2, class vtype3, class vtype4>
- stype & operator << (stype & ofile, const fcn_4obj <stype, vtype1, vtype2, vtype3, vtype4> (im))
- {
- return im (ofile);
- }
- template <class stype, class vtype1, class vtype2, class vtype3, class vtype4>
- stype & operator >> (stype & ifile, const fcn_4obj <stype, vtype1, vtype2, vtype3, vtype4> (im))
- {
- return im (ifile);
- }
|