# Class Row (3.7.0-rc)

3.7.0-rc 3.6.0 (latest) 3.5.0 3.4.0 3.3.0 3.2.0 2.48.0-rc 2.47.1 2.46.0 2.45.0 2.44.0 2.43.0 2.42.0 2.41.0 2.40.0 2.39.0 2.38.0 2.37.0 2.36.0 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.1 2.24.0 2.23.0 2.22.1 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.1 2.14.0 2.13.0 2.12.0 2.11.0 A [`Row`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Row) is a sequence of columns each with a name and an associated [`Value`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Value).
The [`Row`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/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`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Value) data, so copy only when necessary.

[`Row`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/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`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Client#classgoogle_1_1cloud_1_1spanner_1_1Client_1a167955c44cd3ccb46ffe07cad6e7e52b) and [`Client::ExecuteQuery`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/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`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Row)`, and will rarely (if ever) need to construct a`Row\` of their own.

The number of columns in a [`Row`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Row) can be obtained from the [`size()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Row#classgoogle_1_1cloud_1_1spanner_1_1Row_1a5537c9c68eaaba958e822dc221b18c23) member function. The [`Value`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Value)s can be obtained using the [`values()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/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()`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Row#classgoogle_1_1cloud_1_1spanner_1_1Row_1ae749a3e5636511d468bc25cce8714c17) accessor.

Perhaps 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`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/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.

###### 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.

## Operators

### operator=(Row const \&)

Copy and move.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `Row const &` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Row &` |   |

### operator=(Row \&\&)

Copy and move.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
|   | `Row &&` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Row &` |   |

## Functions

### size() const

Returns the number of columns in the row.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::size_t` |   |

### columns() const

Returns the column names for the row.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::vector< std::string > const &` |   |

### values() const \&

Returns the [`Value`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Value) objects in the given row.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::vector< Value > const &` |   |

### values() \&\&

Returns the [`Value`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Value) objects in the given row.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `std::vector< Value > &&` |   |

### get(std::size_t) const

Returns the [`Value`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Value) at the given `pos`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `pos` | `std::size_t` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< Value >` |   |

### get(std::string const \&) const

Returns the [`Value`](https://docs.cloud.google.com/cpp/docs/reference/spanner/latest/classgoogle_1_1cloud_1_1spanner_1_1Value) in the column with `name`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `std::string const &` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< Value >` |   |

### get(Arg \&\&) const

Returns the native C++ value at the given position or column name.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `arg` | `Arg &&` |
| `typename T` | the native C++ type, e.g., std::int64_t or std::string |
| `typename Arg` | a deduced parameter convertible to a std::size_t or std::string |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< T >` |   |

### get() const \&

Returns all the native C++ values for the whole row in a `std::tuple` with the specified type.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `typename Tuple` | the `std::tuple` type that the whole row must unpack into. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< Tuple >` |   |

### get() \&\&

Returns all the native C++ values for the whole row in a `std::tuple` with the specified type.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `typename Tuple` | the `std::tuple` type that the whole row must unpack into. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `StatusOr< Tuple >` |   |