18 void CurryTest::testBasic ()
20 auto sum = [] (
int a,
int b,
int c) {
return a +
b +
c; };
31 void CurryTest::testMoveArgs ()
33 auto func = [] (std::unique_ptr<int>
a, std::unique_ptr<int>
b) {
return *
a + *
b; };
34 QCOMPARE (
Curry (
func) (std::make_unique<int> (1)) (std::make_unique<int> (2)), 3);
40 void CurryTest::testMoveFun ()
42 auto ptr = std::make_unique<int> (10);
43 auto func = [ptr = std::move (ptr)] (std::unique_ptr<int>
a, std::unique_ptr<int>
b) {
return *ptr + *
a + *
b; };
44 QCOMPARE (
Curry (std::move (
func)) (std::make_unique<int> (1)) (std::make_unique<int> (2)), 13);
47 void CurryTest::testRValueFun ()
49 auto sum = [] (
int&&
a,
int&&
b,
int&&
c) {
return a +
b +
c; };
53 void CurryTest::testRefModifications ()
57 auto func = [] (
int&
a,
int&
b) { ++
a; ++
b;
return a +
b; };
68 static inline int DefConstrs_ = 0;
69 static inline int CopyConstrs_ = 0;
70 static inline int CopyAssignments_ = 0;
71 static inline int MoveConstrs_ = 0;
72 static inline int MoveAssignments_ = 0;
73 static inline int Dtors_ = 0;
80 Counter (
const Counter&)
90 Counter& operator= (
const Counter&)
96 Counter& operator= (Counter&&)
109 void CurryTest::testNoExtraCopiesByValue ()
114 auto func = [] (
C1,
C2) {
return 0; };
128 void CurryTest::testNoExtraCopiesByRef ()
133 auto func = [] (
C1&&,
C2&&) {
return 0; };
147 void CurryTest::testNoExtraCopiesByConstRef ()
152 auto func = [] (
const C1&,
const C2&) {
return 0; };
166 void CurryTest::testNoExtraCopiesByConstRefToExisting ()
171 auto func = [] (
const C1&,
const C2&) {
return 0; };
Container< T > Filter(const Container< T > &c, F f)
CurryImpl< std::decay_t< F >, Args... > Curry(F &&f, Args &&... args)