GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
functor.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2008-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_functor_h)
24 #define octave_functor_h 1
25 
26 #include "octave-config.h"
27 
28 template <typename RT, typename PT>
29 class fcn_ptr
30 {
31 public:
32  typedef RT (*TYPE) (PT);
33 };
34 
35 template <typename RT, typename PT>
36 class functor
37 {
38 private:
41 
42 public:
43 
45 
46  RT operator () (PT arg) { return fptr (arg); }
47 };
48 
49 template <typename CT, typename RT, typename PT>
51 {
52 private:
55 
56 public:
57 
59 
60  CT operator () (PT arg) { return CT (fptr (arg)); }
61 };
62 
63 template <typename RT, typename PT>
65 func_ptr (RT (*f) (PT))
66 {
67  return functor<RT, PT> (f);
68 }
69 
70 template <typename CT, typename RT, typename PT>
73 {
75 }
76 
77 #endif
functor< RT, PT > func_ptr(RT(*f)(PT))
Definition: functor.h:65
RT operator()(PT arg)
Definition: functor.h:46
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
functor(fcn_ptr_type p)
Definition: functor.h:44
RT(* TYPE)(PT)
Definition: functor.h:32
octave_value arg
Definition: pr-output.cc:3244
fcn_ptr_type fptr
Definition: functor.h:40
CT operator()(PT arg)
Definition: functor.h:60
fcn_ptr_type fptr
Definition: functor.h:54
fcn_ptr< RT, PT >::TYPE fcn_ptr_type
Definition: functor.h:39
p
Definition: lu.cc:138
functor_with_conversion(fcn_ptr_type p)
Definition: functor.h:58
fcn_ptr< RT, PT >::TYPE fcn_ptr_type
Definition: functor.h:53
functor_with_conversion< CT, RT, PT > func_ptr_with_conversion(RT(*f)(PT))
Definition: functor.h:72