29 using std::placeholders::_1;
41 using lib::meta::typeStr;
59 return ii + freeFun(i2);
65 return 2*ii - fun(i2);
82 return typeStr<typename _Fun<F>::Sig>();
89 return typeStr<typename _Fun<F>::Sig>();
96 return typeStr<typename _Fun<F>::Sig>();
103 return typeStr<typename _Fun<F>::Sig>();
109 using Func = function<int(uint)>;
110 using FuncF = function<int(Functor&, uint)>;
136 CHECK (
"int (Functor::*)(uint)" ==
typeStr<decltype(&Functor::operator())>());
142 Func f3{Functor::staticFun};
143 Func f4{&Functor::staticFun};
149 auto lambda = [&](uint ii) {
return funk.fun(ii); };
153 CHECK (
"int (uint)" == showSig (freeFun));
154 CHECK (
"int (uint)" == showSig (&freeFun));
155 CHECK (
"int (uint)" == showSig (Functor::staticFun));
156 CHECK (
"int (uint)" == showSig (lambda));
157 CHECK (
"int (uint)" == showSig (f5));
160 CHECK (
"int (uint)" == showSigRef (freeFun));
161 CHECK (
"int (uint)" == showSigRef (lambda));
162 CHECK (
"int (uint)" == showSigRef (f5));
164 CHECK (
"int (uint)" == showSigCRef (freeFun));
165 CHECK (
"int (uint)" == showSigCRef (lambda));
166 CHECK (
"int (uint)" == showSigCRef (f5));
168 CHECK (
"int (uint)" == showSigRRef (move(lambda)));
169 CHECK (
"int (uint)" == showSigRRef (move(f5)));
171 CHECK (
"int (uint)" == showSig (move(&freeFun)));
172 CHECK (
"int (uint)" == showSig (move(lambda)));
173 CHECK (
"int (uint)" == showSig (move(f5)));
177 Functor& funkyRef = funk;
178 Func
const& funCRef = f1;
179 Functor
const& funkyCRef = funk;
180 CHECK (
"int (uint)" == showSig (funRef));
181 CHECK (
"int (uint)" == showSig (funkyRef));
182 CHECK (
"int (uint)" == showSig (funCRef));
183 CHECK (
"int (uint)" == showSig (funkyCRef));
186 CHECK (
"int (uint)" ==
typeStr<
_Fun<
int(uint)>::Sig >());
200 auto memfunP = &Functor::fun;
202 Func fMF{bind (fM, funk, _1)};
204 CHECK (
"int (uint)" ==
typeStr<
_Fun<decltype(memfunP)>::Sig>());
205 CHECK (
"int (Functor&, uint)" ==
typeStr<
_Fun<decltype(fM)>::Sig >());
206 CHECK (
"int (uint)" ==
typeStr<
_Fun<decltype(fMF)>::Sig >());
211 CHECK (
_Fun<
int(
long)>::value);
214 auto lambda1 = [](
int i) {
return double(i) / (i*i); };
215 auto lambda2 = [](
auto i) {
return double(i) / (i*i); };
217 using TLamb1 = decltype(lambda1);
218 using TLamb2 = decltype(lambda2);
224 auto stdFunction = function<double(float)> (lambda2);
225 CHECK (
_Fun<decltype(stdFunction)>::value);
227 CHECK (
"double (int)" == showSig (lambda1));
228 CHECK (
"double (float)" == showSig (stdFunction));
Implementation namespace for support and library code.
Metaprogramming tools for transforming functor types.
Simplistic test class runner.