ARowis a sequence of columns each with a name and an associatedValue.
TheRowclass is a regular value type that may be copied, moved, assigned, compared for equality, etc. Instances may be large if they hold lots ofValuedata, so copy only when necessary.
Rowinstances are typically returned as the result of queries or reads of a Cloud Spanner table (seeClient::ReadandClient::ExecuteQuery). Users will mostly just use the accessor methods onRow, and will rarely (if ever) need to construct aRow` of their own.
The number of columns in aRowcan be obtained from thesize()member function. TheValues can be obtained using thevalues()accessor. The names of each column in the row can be obtained using thecolumns()accessor.
Perhaps the most convenient way to access theValuesin a row is through the variety of "get" accessors. A user may access a column'sValueby callinggetwith astd::size_t0-indexed position, or astd::stringcolumn name. Furthermore, callers may directly extract the native C++ type by specifying the C++ type along with the column's position or name.
Example
Row row = ...;
if (StatusOr<std::string> x = row.get<std::string>("LastName")) {
std::cout << "LastName=" << *x << "\n";
}
Constructors
Row(Row const &)
Copy and move.
Parameter
Name
Description
Row const &
Row(Row &&)
Copy and move.
Parameter
Name
Description
Row &&
Row()
Default constructs an empty row with no columns nor values.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe webpage provides documentation for the \u003ccode\u003eRow\u003c/code\u003e class within the Google Cloud Spanner C++ library, offering access to various versions of the class.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eRow\u003c/code\u003e represents a sequence of named columns, each with an associated \u003ccode\u003eValue\u003c/code\u003e, and is typically returned from queries or reads of a Cloud Spanner table.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRow\u003c/code\u003e class allows for copying, moving, assignment, and comparison, but since instances can be large, copying should be done judiciously.\u003c/p\u003e\n"],["\u003cp\u003eUsers can access column \u003ccode\u003eValues\u003c/code\u003e by position or name, and they can directly extract native C++ types from these columns.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRow\u003c/code\u003e class also provides methods to retrieve the number of columns (\u003ccode\u003esize()\u003c/code\u003e), the names of the columns (\u003ccode\u003ecolumns()\u003c/code\u003e), and the \u003ccode\u003eValue\u003c/code\u003e objects within the row (\u003ccode\u003evalues()\u003c/code\u003e).\u003c/p\u003e\n"]]],[],null,["# Class Row (2.26.0)\n\nVersion 2.26.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.41.0](/cpp/docs/reference/spanner/2.41.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.40.0](/cpp/docs/reference/spanner/2.40.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.39.0](/cpp/docs/reference/spanner/2.39.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.38.0](/cpp/docs/reference/spanner/2.38.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.37.0](/cpp/docs/reference/spanner/2.37.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.36.0](/cpp/docs/reference/spanner/2.36.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.35.0](/cpp/docs/reference/spanner/2.35.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.34.0](/cpp/docs/reference/spanner/2.34.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.33.0](/cpp/docs/reference/spanner/2.33.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.32.0](/cpp/docs/reference/spanner/2.32.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.31.0](/cpp/docs/reference/spanner/2.31.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.30.0](/cpp/docs/reference/spanner/2.30.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.29.0](/cpp/docs/reference/spanner/2.29.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.28.0](/cpp/docs/reference/spanner/2.28.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.27.0](/cpp/docs/reference/spanner/2.27.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.26.0](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.25.1](/cpp/docs/reference/spanner/2.25.1/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.24.0](/cpp/docs/reference/spanner/2.24.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.23.0](/cpp/docs/reference/spanner/2.23.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.22.1](/cpp/docs/reference/spanner/2.22.1/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.21.0](/cpp/docs/reference/spanner/2.21.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.20.0](/cpp/docs/reference/spanner/2.20.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.19.0](/cpp/docs/reference/spanner/2.19.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.18.0](/cpp/docs/reference/spanner/2.18.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.17.0](/cpp/docs/reference/spanner/2.17.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.16.0](/cpp/docs/reference/spanner/2.16.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.15.1](/cpp/docs/reference/spanner/2.15.1/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.14.0](/cpp/docs/reference/spanner/2.14.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.13.0](/cpp/docs/reference/spanner/2.13.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.12.0](/cpp/docs/reference/spanner/2.12.0/classgoogle_1_1cloud_1_1spanner_1_1Row)\n- [2.11.0](/cpp/docs/reference/spanner/2.11.0/classgoogle_1_1cloud_1_1spanner_1_1Row) \nA [`Row`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Row) is a sequence of columns each with a name and an associated [`Value`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Value). \nThe [`Row`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Row) class is a regular value type that may be copied, moved, assigned, compared for equality, etc. Instances may be large if they hold lots of [`Value`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Value) data, so copy only when necessary.\n\n[`Row`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Row) instances are typically returned as the result of queries or reads of a Cloud Spanner table (see [`Client::Read`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a167955c44cd3ccb46ffe07cad6e7e52b) and [`Client::ExecuteQuery`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a8e2afee42f535c0436d9161c54b84179)). Users will mostly just use the accessor methods on [`Row`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Row)`, and will rarely (if ever) need to construct a`Row\\` of their own.\n\nThe number of columns in a [`Row`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Row) can be obtained from the [`size()`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Row#classgoogle_1_1cloud_1_1spanner_1_1Row_1a5537c9c68eaaba958e822dc221b18c23) member function. The [`Value`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Value)s can be obtained using the [`values()`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Row#classgoogle_1_1cloud_1_1spanner_1_1Row_1a7c6404fe998782c3211d2ba53d73d592) accessor. The names of each column in the row can be obtained using the [`columns()`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Row#classgoogle_1_1cloud_1_1spanner_1_1Row_1ae749a3e5636511d468bc25cce8714c17) accessor.\n\nPerhaps the most convenient way to access the `Values` in a row is through the variety of \"get\" accessors. A user may access a column's [`Value`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Value) by calling `get` with a `std::size_t` 0-indexed position, or a `std::string` column name. Furthermore, callers may directly extract the native C++ type by specifying the C++ type along with the column's position or name.\n\n###### Example\n\n Row row = ...;\n if (StatusOr\u003cstd::string\u003e x = row.get\u003cstd::string\u003e(\"LastName\")) {\n std::cout \u003c\u003c \"LastName=\" \u003c\u003c *x \u003c\u003c \"\\n\";\n }\n\nConstructors\n------------\n\n### Row(Row const \\&)\n\nCopy and move.\n\n### Row(Row \\&\\&)\n\nCopy and move.\n\n### Row()\n\nDefault constructs an empty row with no columns nor values.\n\nOperators\n---------\n\n### operator=(Row const \\&)\n\nCopy and move.\n\n### operator=(Row \\&\\&)\n\nCopy and move.\n\nFunctions\n---------\n\n### size() const\n\nReturns the number of columns in the row.\n\n### columns() const\n\nReturns the column names for the row.\n\n### values() const \\&\n\nReturns the [`Value`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Value) objects in the given row.\n\n### values() \\&\\&\n\nReturns the [`Value`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Value) objects in the given row.\n\n### get(std::size_t) const\n\nReturns the [`Value`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Value) at the given `pos`.\n\n### get(std::string const \\&) const\n\nReturns the [`Value`](/cpp/docs/reference/spanner/2.26.0/classgoogle_1_1cloud_1_1spanner_1_1Value) in the column with `name`.\n\n### get(Arg \\&\\&) const\n\nReturns the native C++ value at the given position or column name.\n\n### get() const \\&\n\nReturns all the native C++ values for the whole row in a `std::tuple` with the specified type.\n\n### get() \\&\\&\n\nReturns all the native C++ values for the whole row in a `std::tuple` with the specified type."]]