00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_FUN_C_HH
00027 # define MLN_FUN_C_HH
00028
00036
00037 # include <mln/fun/internal/selector.hh>
00038 # include <mln/metal/unqualif.hh>
00039
00040
00041 namespace mln
00042 {
00043
00045 template <typename E>
00046 struct C_Function;
00047
00048
00050 template <typename R, typename A>
00051 struct category< R (*)(A) >
00052 {
00053 typedef C_Function<void> ret;
00054 };
00055
00056
00057
00058
00059 namespace fun { template <typename F> struct C; }
00060
00061
00062
00063 namespace trait
00064 {
00065
00066 template <template <class> class Op,
00067 typename R, typename A>
00068 struct set_unary_< Op, C_Function, R (*)(A) >
00069 {
00070 typedef Op< fun::C<R (*)(A)> > Op_;
00071 typedef typename Op_::ret ret;
00072 };
00073
00074 template <template <class, class> class Op,
00075 typename O,
00076 typename R, typename A>
00077 struct set_binary_< Op,
00078 Object, O,
00079 C_Function, R (*)(A) >
00080 {
00081 typedef Op< O, fun::C<R (*)(A)> > Op_;
00082 typedef typename Op_::ret ret;
00083 };
00084
00085 }
00086
00087
00088
00089 namespace fun
00090 {
00091
00092 template <typename F> struct C;
00093
00094
00095
00096 template <typename R, typename A>
00097 struct C< R (*)(A) >
00098 :
00099 fun::internal::selector_< R, A, C<R(*)(A)> >::ret
00100 {
00101 C();
00102 C(R (*f)(A));
00103 typedef R result;
00104 R operator()(const mlc_unqualif(A)& a) const;
00105 protected:
00106 R (*f_)(A);
00107 };
00108
00109
00110 # ifndef MLN_INCLUDE_ONLY
00111
00112 template <typename R, typename A>
00113 inline
00114 C<R(*)(A)>::C()
00115 {
00116 }
00117
00118 template <typename R, typename A>
00119 inline
00120 C<R(*)(A)>::C(R (*f)(A))
00121 : f_(f)
00122 {
00123 }
00124
00125 template <typename R, typename A>
00126 inline
00127 R
00128 C<R(*)(A)>::operator()(const mlc_unqualif(A)& a) const
00129 {
00130 return f_(a);
00131 }
00132
00133 # endif // ! MLN_INCLUDE_ONLY
00134
00135 }
00136
00137 }
00138
00139
00140 #endif // ! MLN_FUN_C_HH