mirror of
https://github.com/boostorg/pfr.git
synced 2026-01-19 04:22:13 +00:00
more polishings for the docs
This commit is contained in:
19
doc/pfr.qbk
19
doc/pfr.qbk
@@ -26,7 +26,7 @@ using auth_info_tuple = std::tuple<
|
||||
std::time_t
|
||||
>;
|
||||
|
||||
struct auth_info_aggreagte {
|
||||
struct auth_info_aggregate {
|
||||
std::int64_t id;
|
||||
std::int64_t session_id;
|
||||
std::int64_t source_id;
|
||||
@@ -34,7 +34,7 @@ struct auth_info_aggreagte {
|
||||
};
|
||||
```
|
||||
|
||||
Definition via structure is much more clear. Same story with usages: `return std::get<1>(value);` vs. `return value.session_id;`.
|
||||
Definition via [@https://en.cppreference.com/w/cpp/language/aggregate_initialization aggregate initializable] structure is much more clear. Same story with usages: `return std::get<1>(value);` vs. `return value.session_id;`.
|
||||
|
||||
Another advantage of aggregates is a more efficient copy, move construction and assignments.
|
||||
|
||||
@@ -77,17 +77,18 @@ Depending on the usage of PFR in your DB wrapper users code will look differentl
|
||||
[[
|
||||
```
|
||||
user_info retrieve_friend(std::string_view name) {
|
||||
auto tuple_info = db::one_row_as<std::int64_t, std::string, std::int64_t>(
|
||||
std::tuple<<std::int64_t, std::string, std::int64_t>> info
|
||||
= db::one_row_as<std::int64_t, std::string, std::int64_t>(
|
||||
"SELECT id, name, github_stars, email FROM user_infos WHERE name=$0",
|
||||
name
|
||||
);
|
||||
|
||||
auto friend_info = ask_user_for_friend(
|
||||
user_info{
|
||||
std::move(std::get<0>(tuple_info)),
|
||||
std::move(std::get<1>(tuple_info)),
|
||||
std::move(std::get<2>(tuple_info)),
|
||||
std::move(std::get<3>(tuple_info)),
|
||||
std::move(std::get<0>(info)),
|
||||
std::move(std::get<1>(info)),
|
||||
std::move(std::get<2>(info)),
|
||||
std::move(std::get<3>(info)),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -106,12 +107,12 @@ user_info retrieve_friend(std::string_view name) {
|
||||
][
|
||||
```
|
||||
user_info retrieve_friend(std::string_view name) {
|
||||
const auto info = db::one_row_as<user_info>(
|
||||
user_info info = db::one_row_as<user_info>(
|
||||
"SELECT id, name, github_stars, email FROM user_infos WHERE name=$0",
|
||||
name
|
||||
);
|
||||
|
||||
auto friend_info = ask_user_for_friend(info);
|
||||
auto friend_info = ask_user_for_friend(std::move(info));
|
||||
|
||||
db::insert(
|
||||
"INSERT INTO user_infos(id, name, github_stars, email) VALUES ($0, $1, $2, $3)",
|
||||
|
||||
Reference in New Issue
Block a user