38 using std::placeholders::_1;
50 using lib::meta::typeStr;
68 return ii + freeFun(i2);
74 return 2*ii - fun(i2);
91 return typeStr<typename _Fun<F>::Sig>();
98 return typeStr<typename _Fun<F>::Sig>();
105 return typeStr<typename _Fun<F>::Sig>();
112 return typeStr<typename _Fun<F>::Sig>();
118 using Func = function<int(uint)>;
119 using FuncF = function<int(Functor&, uint)>;
145 CHECK (
"int (Functor::*)(unsigned int)" ==
typeStr<decltype(&Functor::operator())>());
151 Func f3{Functor::staticFun};
152 Func f4{&Functor::staticFun};
158 auto lambda = [&](uint ii) {
return funk.fun(ii); };
162 CHECK (
"int (unsigned int)" == showSig (freeFun));
163 CHECK (
"int (unsigned int)" == showSig (&freeFun));
164 CHECK (
"int (unsigned int)" == showSig (Functor::staticFun));
165 CHECK (
"int (unsigned int)" == showSig (lambda));
166 CHECK (
"int (unsigned int)" == showSig (f5));
169 CHECK (
"int (unsigned int)" == showSigRef (freeFun));
170 CHECK (
"int (unsigned int)" == showSigRef (lambda));
171 CHECK (
"int (unsigned int)" == showSigRef (f5));
173 CHECK (
"int (unsigned int)" == showSigCRef (freeFun));
174 CHECK (
"int (unsigned int)" == showSigCRef (lambda));
175 CHECK (
"int (unsigned int)" == showSigCRef (f5));
177 CHECK (
"int (unsigned int)" == showSigRRef (move(lambda)));
178 CHECK (
"int (unsigned int)" == showSigRRef (move(f5)));
180 CHECK (
"int (unsigned int)" == showSig (move(&freeFun)));
181 CHECK (
"int (unsigned int)" == showSig (move(lambda)));
182 CHECK (
"int (unsigned int)" == showSig (move(f5)));
186 Functor& funkyRef = funk;
187 Func
const& funCRef = f1;
188 Functor
const& funkyCRef = funk;
189 CHECK (
"int (unsigned int)" == showSig (funRef));
190 CHECK (
"int (unsigned int)" == showSig (funkyRef));
191 CHECK (
"int (unsigned int)" == showSig (funCRef));
192 CHECK (
"int (unsigned int)" == showSig (funkyCRef));
195 CHECK (
"int (unsigned int)" ==
typeStr<
_Fun<
int(uint)>::Sig >());
209 auto memfunP = &Functor::fun;
211 Func fMF{bind (fM, funk, _1)};
213 CHECK (
"int (unsigned int)" ==
typeStr<
_Fun<decltype(memfunP)>::Sig>());
214 CHECK (
"int (Functor&, unsigned int)" ==
typeStr<
_Fun<decltype(fM)>::Sig >());
215 CHECK (
"int (unsigned int)" ==
typeStr<
_Fun<decltype(fMF)>::Sig >());
220 CHECK (
_Fun<
int(
long)>::value);
223 auto lambda1 = [](
int i) {
return double(i) / (i*i); };
224 auto lambda2 = [](
auto i) {
return double(i) / (i*i); };
226 using TLamb1 = decltype(lambda1);
227 using TLamb2 = decltype(lambda2);
233 auto stdFunction = function<double(float)> (lambda2);
234 CHECK (
_Fun<decltype(stdFunction)>::value);
236 CHECK (
"double (int)" == showSig (lambda1));
237 CHECK (
"double (float)" == showSig (stdFunction));
Implementation namespace for support and library code.
Metaprogramming tools for transforming functor types.
Simple test class runner.