I have asked a similar question before overloading operator >> for lambdas
But i did not explained what i really wanted .
I am writing a simple wrapper around sqlite3 C api .
this is my project on github => sqlite modern cpp
I want to overload the >> operator for lambdas.
I want the fallowing code to work :
database db("dbfile.db");
db << "select age,name,weight from user where age > ? ;"
<< 18
>> [&](int age, string name, double weight) {
cout << age << ' ' << name << ' ' << weight << endl;
};
I want the idea! that is why i abstracted the question in my previous question.
I have a database_bind
class which is returned by the '<<' operator ,
i want to be able to overload >> operator on database_bind
class
for lambdas with different number of arguments.
Currently i'm supporting this syntax :
db << "select age,name,weight from user where age > ? ;"
<< 18
>> function<void(int,string,double)>([&](int age, string name, double weight) {
cout << age << ' ' << name << ' ' << weight << endl;
});
See Question&Answers more detail:os