For any query q, you can call q.select(exprn0, exprn1, ... ),
provided that:
exprni is an abstract_mapper<Ti> for some mapped type Ti
(this is checked at compile time),
exprnis that do and don't
use an aggregate function complies with SQL rules (checked at run
time). In practice this means that either none do or all do.
q's value mapper will be visible
to each exprni.
q.select(exprn0, exprn1, ... )
returns a query with
the following characteristics:
std::tuple<T0, T1, ...>.
tuple_mapper<T0, T1, ...>,
in which each member mapper is identical to the respective exprni.
exprnis contains an aggregate
function, then:
std::tuples,
evaluated using successive records of q's
output.
exprnis,
using the current record from q,
and collecting the results into a std::tuple.
exprnis contain an aggregate
function, then:
std::tuple.
exprnis,
based on the totality of q's output,
and collecting the results into a std::tuple.
// Most typical case: Each of these queries produces one tuple per point in points: // const query<std::tuple<float, float>> swap = points .select(points->y, points->x); const query<std::tuple<float, float>> pluses_and_minuses = points .select(points->x + points->y, points->x - points->y); // Practise using a query of tuples: // const query<float> pluses_times_minuses = pluses_and_minuses .select(pluses_and_minuses->get<0>() * pluses_and_minuses->get<1>()); // Use operator* to get points's entire value mapper: // const query<std::tuple<point, float, float>> points_and_pluses_and_minuses = points .select(*points, points->x + points->y, points->x - points->y); // Classes are statically mapped; therefore points_and_pluses_and_minuses->get<0>() // is not just an abstract_mapper<point>, it's a class_mapper<point>. // So we can use its class_mapper features, e.g. ".x": // const query<float> xs_times_pluses = points_and_pluses_and_minuses .select(points_and_pluses_and_minuses->get<0>().x * points_and_pluses_and_minuses->get<1>()); // points_and_pluses_and_minuses->get<0>() is strictly identical to *point, // so we can use one instead of the other (stylistically questionable though): // const query<float> xs_times_pluses_again = points_and_pluses_and_minuses .select(points->x * points_and_pluses_and_minuses->get<1>());