template <typename T>

class Box

Defined at line 42 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

|Box

<T

>| is a wrapper around |std::unique_ptr

<T

>| that changes the behavior

of `operator==` from pointer equality to value equality:

- If one box holds a value while the other doesn't, they are not equal.

- If both boxes don't hold values, they are equal.

- Otherwise, delegate to `operator==` of |T|.

|Box

<T

>| can be implicitly converted from an |std::unique_ptr

<T

>|.

The primary purpose is that users will be able to use |std::unique_ptr

<T

>|

in their application, and assign their data into natural domain objects

with minimal syntax burden:

fidl::Box

<T

> box = std::make_unique

<T

>(...);

|Box

<T

>| will be used to express optionality in the natural domain objects in

cases where the value need to be stored on the heap to break reference cycles

from recursively referencing types. Overall, this makes `operator==` the

standard way to compare objects for deep equality in FIDL types.

Public Methods

void Box<T> ()

Defined at line 44 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

void ~Box<T> ()

Defined at line 45 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

void Box<T> (Box<T> && other)

Defined at line 46 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

Box<T> & operator= (Box<T> && other)

Defined at line 47 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

void Box<T> (std::unique_ptr<T> ptr)

Support for directly assigning |unique_ptr|s into natural domain object

fields which are |Box|es.

NOLINTNEXTLINE

Defined at line 53 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

bool has_value ()

A std::optional-like API:

Defined at line 64 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

const T & value ()

Defined at line 66 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

T & value ()

Defined at line 70 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

template <class U>
T value_or (U && default_value)

Defined at line 76 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

std::unique_ptr<T> & unique_ptr ()

Returns the wrapped |unique_ptr|.

Defined at line 84 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h

const std::unique_ptr<T> & unique_ptr ()

Defined at line 85 of file ../../sdk/lib/fidl/cpp/include/lib/fidl/cpp/box.h