-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fn_foreach.cpp
62 lines (46 loc) · 1.49 KB
/
Fn_foreach.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "../Fn_foreach.hpp"
#include <iostream>
#include <tdb/tdb_sqlite.hpp>
//test code
namespace{
[[maybe_unused]] void example(){
typedef tdb::Tag_sqlite Tag_xxx;
tdb::Connection_t<Tag_xxx> connection("/tmp/test.sqlite");
//--- Fn_foreach (void) ---
//multi thread
tdb::Fn_foreach<
Tag_xxx ,
std::tuple<int>,
std::tuple<double,double>,
true
> fn_foreach(connection, "select i1 from test where d1 != $1 and d2 != $2");
fn_foreach( [](int i){std::cout <<i<<std::endl;}, 1.0,1.0);
//single thread
tdb::Fn_foreach<
Tag_xxx ,
std::tuple<int>,
std::tuple<double,double>,
false
> fn_foreach2(connection, "select i1 from test where d1 != $1 and d2 != $2");
fn_foreach2( [](int i){std::cout <<i<<std::endl;}, 1.0,1.0);
std::cout << "Fn_foreach (void) "<<std::endl;
//--- Fn_foreach (bool) ---
//multi thread
tdb::Fn_foreach<
Tag_xxx ,
std::tuple<int>,
std::tuple<double,double>,
true
> fn_foreach3(connection, "select i1 from test where d1 != $1 and d2 != $2");
[[maybe_unused]] bool b1 = fn_foreach3( [](int i)->bool{std::cout <<i<<std::endl; return true;}, 1.0,1.0);
//single thread
tdb::Fn_foreach<
Tag_xxx ,
std::tuple<int>,
std::tuple<double,double>,
false
> fn_foreach4(connection, "select i1 from test where d1 != $1 and d2 != $2");
[[maybe_unused]] bool b2 = fn_foreach4( [](int i)->bool{std::cout <<i<<std::endl; return true;}, 1.0,1.0);
std::cout << "Fn_foreach (void) "<<std::endl;
}
}