3.8.0-rc 3.7.0 (latest) 3.6.0 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 The [Value](https://docs.cloud.google.com/cpp/docs/reference/bigtable/latest/classgoogle_1_1cloud_1_1bigtable_1_1Value) class represents a type-safe, nullable Bigtable value.
For now, this is a minimal class to unblock further development of the Bigtable GoogleSQL feature. It is conceptually similar to a `std::any` except the only allowed types will be those supported by Bigtable, and a "null" value (similar to a `std::any` without a value) still has an associated type. The supported types are shown in the following table along with how they map to the Bigtable types (<https://cloud.google.com/bigtable/docs/data-types>):

| Bigtable Type | C++ Type `T` |
|---|---|
| BOOL | `bool` |
| INT64 | `std::int64_t` |
| FLOAT32 | `float` |
| FLOAT64 | `double` |
| STRING | `std::string` |
| BYTES | [`google::cloud::bigtable::Bytes`](https://docs.cloud.google.com/cpp/docs/reference/bigtable/latest/classgoogle_1_1cloud_1_1bigtable_1_1Bytes) |
| TIMESTAMP | [`google::cloud::bigtable::Timestamp`](https://docs.cloud.google.com/cpp/docs/reference/bigtable/latest/classgoogle_1_1cloud_1_1bigtable_1_1Timestamp) |
| DATE | `absl::CivilDay` |
| ARRAY | `std::vector<T>` // \[1\] |
| STRUCT | `std::tuple<Ts...>` |
| MAP | `std::unordered_map<K, V>` // \[2\] |

\[1\] The type `T` may be any of the other supported types, except for ARRAY/`std::vector`. \[2\] The type `K` may be any of [`Bytes`](https://docs.cloud.google.com/cpp/docs/reference/bigtable/latest/classgoogle_1_1cloud_1_1bigtable_1_1Bytes), `std::string`, and `std::int64_t`.

Callers may create instances by passing any of the supported values (shown in the table above) to the constructor. "Null" values are created using the `MakeNullValue<T>()` factory function or by passing an empty `std::optional<T>` to the [Value](https://docs.cloud.google.com/cpp/docs/reference/bigtable/latest/classgoogle_1_1cloud_1_1bigtable_1_1Value) constructor.

###### Bigtable Arrays

Bigtable arrays are represented in C++ as a `std::vector<T>`, where the type `T` may be any of the other allowed Bigtable types, such as `bool`, `std::int64_t`, etc. The only exception is that arrays may not directly contain another array; to achieve a similar result you could create an array of a 1-element struct holding an array. The following examples show usage of arrays.

    std::vector<std::int64_t> vec = {1, 2, 3, 4, 5};
    bigtable::Value v(vec);
    auto copy = *v.get<std::vector<std::int64_t>>();
    assert(vec == copy);

###### Bigtable Structs

Bigtable structs are represented in C++ as instances of `std::tuple` holding zero or more of the allowed Bigtable types, such as `bool`, `std::int64_t`, `std::vector`, and even other `std::tuple` objects. Each tuple element corresponds to a single field in a Bigtable STRUCT.

Bigtable STRUCT fields may optionally contain a string indicating the field's name. Fields names may be empty, unique, or repeated. A named field may be specified as a tuple element of type `std::pair<std::string, T>`, where the pair's `.first` member indicates the field's name, and the `.second` member is any valid Bigtable type `T`.

    using Struct = std::tuple<bool, std::pair<std::string, std::int64_t>>;
    Struct s  = {true, {"Foo", 42}};
    bigtable::Value v(s);
    assert(s == *v.get<Struct>());

> [!NOTE]
> **Note:** While a STRUCT's (optional) field names are not part of its C++ type, they are part of its Bigtable STRUCT type. Array's (i.e., `std::vector`) must contain a single element type, therefore it is an error to construct a `std::vector` of `std::tuple` objects with differently named fields.

###### Bigtable Maps

Bigtable maps are represented in C++ as a `std::unordered_map<K, V>`, where the type `K` may be any of [`Bytes`](https://docs.cloud.google.com/cpp/docs/reference/bigtable/latest/classgoogle_1_1cloud_1_1bigtable_1_1Bytes), `std::string` or `std::int64_t`. Normally encoded Map values won't have repeated keys, however, this client handles the case as follows: if the same key appears multiple times, the *last* value takes precedence.

The following examples show usage of maps.

    std::unordered_map<std::string, std::unordered_map<std::string,
    std::int64_t>> m = {{"map1",
    {{"key1", 1}}, "map2": {{"key2", 2}}};
    bigtable::Value mv(m);
    auto copy = *v.get<std::unordered_map<std::string, std::int64_t>>>();
    assert(m == copy);

## Constructors

### Value()

Constructs a [`Value`](https://docs.cloud.google.com/cpp/docs/reference/bigtable/latest/classgoogle_1_1cloud_1_1bigtable_1_1Value) that holds nothing.

### Value(bool)

Constructs an instance with the specified type and value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `bool` |

### Value(std::int64_t)

Constructs an instance with the specified type and value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::int64_t` |

### Value(float)

Constructs an instance with the specified type and value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `float` |

### Value(double)

Constructs an instance with the specified type and value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `double` |

### Value(std::string)

Constructs an instance with the specified type and value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::string` |

### Value(Bytes const \&)

Constructs an instance with the specified type and value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `Bytes const &` |

### Value(Timestamp const \&)

Constructs an instance with the specified type and value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `Timestamp const &` |

### Value(absl::CivilDay const \&)

Constructs an instance with the specified type and value.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `absl::CivilDay const &` |

### Value(int)

Constructs an instance from common C++ literal types that closely, though not exactly, match supported Bigtable types.
An integer literal in C++ is of type `int`, which is not exactly an allowed Bigtable type. This will be allowed but it will be implicitly up converted to a `std::int64_t`. Similarly, a C++ string literal will be implicitly converted to a `std::string`. For example:

    bigtable::Value v1(42);
    assert(42 == *v1.get<std::int64_t>());

    bigtable::Value v2("hello");
    assert("hello" == *v2.get<std::string>());

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `int` |

### Value(char const \*)

Constructs an instance from common C++ literal types that closely, though not exactly, match supported Bigtable types.
An integer literal in C++ is of type `int`, which is not exactly an allowed Bigtable type. This will be allowed but it will be implicitly up converted to a `std::int64_t`. Similarly, a C++ string literal will be implicitly converted to a `std::string`. For example:

    bigtable::Value v1(42);
    assert(42 == *v1.get<std::int64_t>());

    bigtable::Value v2("hello");
    assert("hello" == *v2.get<std::string>());

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `v` | `char const *` |

### Value(std::optional\< T \>)

Constructs a non-null instance if `opt` has a value, otherwise constructs a null instance with the specified type `T`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `opt` | `std::optional< T >` |
| `typename T` |   |

### Value(std::vector\< T \>)

Constructs an instance from a Bigtable ARRAY of the specified type and values.
The type `T` may be any valid type shown above, except vectors of vectors are not allowed.

> [!WARNING]
> **Warning:** If `T` is a `std::tuple` with field names (i.e., at least one of its element types is a `std::pair<std::string, T>`) then, all of the vector's elements must have exactly the same field names. Any mismatch in in field names results in undefined behavior.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `v` | `std::vector< T >` |
| `typename T` |   |

### Value(std::tuple\< Ts... \>)

Constructs an instance from a Bigtable STRUCT with a type and values matching the given `std::tuple`.
Any STRUCT field may optionally have a name, which is specified as `std::pair<std::string, T>`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `tup` | `std::tuple< Ts... >` |
| `typename...` |   |

### Value(std::unordered_map\< K, V \>)

Constructs an instance from a Bigtable MAP with a type and values matching the given `std::unordered_map`.

> [!WARNING]
> **Warning:** if the same key appears multiple times, the *last* value takes precedence.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `m` | `std::unordered_map< K, V >` |
| `typename K` |   |
| `typename V` |   |

### Value(Value const \&)

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

### Value(Value \&\&)

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

## Operators

### operator=(Value const \&)

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

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

### operator=(Value \&\&)

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

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

## Functions

### get() const \&

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `typename T` |   |

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

### get() \&\&

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `typename T` |   |

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

### is_null() const

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### static IsNullValue(google::bigtable::v2::Value const \&)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `google::bigtable::v2::Value const &` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

### static TypeAndValuesMatch(google::bigtable::v2::Type const \&, google::bigtable::v2::Value const \&, int)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `type` | `google::bigtable::v2::Type const &` |
| `value` | `google::bigtable::v2::Value const &` |
| `depth` | `int` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Status` |   |