mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-06 05:00:37 -06:00
Merge pull request #143 from theodelrieu/develop
Enhancements to result_t::iterator
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "MockDb.h"
|
||||
#include "Sample.h"
|
||||
#include "is_regular.h"
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sqlpp11/alias_provider.h>
|
||||
#include <sqlpp11/connection.h>
|
||||
@@ -52,6 +53,14 @@ struct to_cerr
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Row>
|
||||
void print_row(Row const& row)
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
const std::string b = row.beta;
|
||||
std::cout << a << ", " << b << std::endl;
|
||||
}
|
||||
|
||||
int Select(int, char* [])
|
||||
{
|
||||
MockDb db = {};
|
||||
@@ -69,6 +78,13 @@ int Select(int, char* [])
|
||||
std::cout << row.a << std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
// using stl algorithms
|
||||
auto rows = db(select(all_of(t)).from(t).unconditionally());
|
||||
// nicer in C++14
|
||||
std::for_each(rows.begin(), rows.end(), &print_row<decltype(*rows.begin())>);
|
||||
}
|
||||
|
||||
for (const auto& row : db(select(all_of(t)).from(t).unconditionally()))
|
||||
{
|
||||
int64_t a = row.alpha;
|
||||
|
||||
Reference in New Issue
Block a user