Skip to content

Instantly share code, notes, and snippets.

Last active Aug 21, 2019
What would you like to do?
Automatic marshaling of C++ functions into SQL user functions
#include "SQLiteWrapper.h"
std::string reverse(std::string str) {
std::reverse(str.begin(), str.end());
return str;
int main(void) {
static const char reverse_name[] = "reverse";
static const char db_name[] = ":memory:";
using db = sqlite::Database<db_name>;
static const char select_query[] = "select reverse(?1)";
auto fetch_row = db::query<select_query>("hello world!");
std::string_view str;
while (fetch_row(str)) {
std::cout << str << std::endl;
Copy link

patrick-palka commented Aug 21, 2019

Output: !dlrow olleh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment