Commit Graph

7 Commits

Author SHA1 Message Date
Ben Wagner
159ae198d3 Test skstd::optional calls emplaced T's destructor
The skstd::optional already does this correctly, but it appears to be
one of the guarantees of this class which isn't tested.

Change-Id: Iedd9004496f10c1ec56da4ebc5e246880c9a457f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/467781
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2021-11-04 16:06:46 +00:00
John Stiles
aca3f22491 Add skstd::optional::emplace.
Change-Id: I178ae881191e8ed7ce5399e806838a44d2358e31
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442319
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-26 19:03:29 +00:00
Herb Derby
d390c642ac add value_or to optional
Add full compliment of operator*, have them assert in debug,
but not throw in release as per c++ spec.

Add full compliment of value() have them crash if there is
no value as per the c++ spec.

Add value_or.

Add test for value_or.

Change-Id: Ib0d9a01fba367768e66d00fbc61b471397e8582c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425476
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-07-07 23:08:17 +00:00
John Stiles
e2c4e7e62d Add comparison operators to skstd::optional.
This involves a significant number of overloads, as optionals can be
compared against other optionals, or nullopt, or a value; either side
can mix and match as desired.

Change-Id: I26b8420e417300d32569fc76a55bcfd8e01eb322
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420576
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-22 21:11:15 +00:00
John Stiles
e53cf99728 Add nullopt to skstd::optional.
Change-Id: Ie0ed256fce79e2a03fcd468c820f468dc8bf25b5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420536
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-22 17:19:55 +00:00
Ethan Nicholas
8f73edeaf6 Added more SkTOptional APIs
This adds copy constructors / assignment operator, reset(), value(), and
has_value() to SkTOptional.

Change-Id: I564552a75a4c612685cdaa8e80e4359b394b64a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414338
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-01 18:54:13 +00:00
Ethan Nicholas
4ed2baa981 Added skstd::optional
This is needed by the upcoming DSLParser.

Change-Id: I54a0714e55feeb78894df766b14c795970f2c2d4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411308
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-25 14:10:11 +00:00