I want to do something like this
function A(){
session database_handler(....);
result res = database_handler << "SELECT ....";
functionB(res);
}
what should the parameters of functionB be?
Passing it as a pointer does not work, neither as in the example.
Thanks
You can safely copy cppdb::result
but you may iterate over it only in one location. i.e. cppdb::result
holds a reference (counted) to the result object so if you iterate over rows in functionB
you can't iterate over them in functionA
So you can safely define
void functionB(cppdb::result res);
However it would be the same in terms of iterating as
void functionB(cppdb::result &res);
Also the last one faster as it does not involve reference counting overhead.