mirror of
https://github.com/TartanLlama/optional.git
synced 2025-07-30 09:57:13 +02:00
Merge branch 'master' of github.com:TartanLlama/optional
This commit is contained in:
10
README.md
10
README.md
@ -8,7 +8,7 @@ MSVC: [ {
|
std::optional<image> get_cute_cat (const image& img) {
|
||||||
auto cropped = crop_to_cat(img);
|
auto cropped = crop_to_cat(img);
|
||||||
if (!cropped) {
|
if (!cropped) {
|
||||||
@ -31,7 +31,7 @@ std::optional<image> get_cute_cat (const image& img) {
|
|||||||
|
|
||||||
You can do this:
|
You can do this:
|
||||||
|
|
||||||
```
|
```c++
|
||||||
tl::optional<image> get_cute_cat (const image& img) {
|
tl::optional<image> get_cute_cat (const image& img) {
|
||||||
return crop_to_cat(img)
|
return crop_to_cat(img)
|
||||||
.and_then(add_bow_tie)
|
.and_then(add_bow_tie)
|
||||||
@ -68,7 +68,7 @@ The interface is the same as `std::optional`, but the following member functions
|
|||||||
|
|
||||||
In addition to those member functions, optional references are also supported:
|
In addition to those member functions, optional references are also supported:
|
||||||
|
|
||||||
```
|
```c++
|
||||||
int i = 42;
|
int i = 42;
|
||||||
tl::optional<int&> o = i;
|
tl::optional<int&> o = i;
|
||||||
*o == 42; //true
|
*o == 42; //true
|
||||||
@ -79,7 +79,7 @@ i = 12;
|
|||||||
|
|
||||||
Assignment has rebind semantics rather than assign-through semantics:
|
Assignment has rebind semantics rather than assign-through semantics:
|
||||||
|
|
||||||
```
|
```c++
|
||||||
int j = 8;
|
int j = 8;
|
||||||
o = j;
|
o = j;
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ Tested on:
|
|||||||
* g++ 8.0.1
|
* g++ 8.0.1
|
||||||
* g++ 7.3
|
* g++ 7.3
|
||||||
* g++ 6.4
|
* g++ 6.4
|
||||||
* g++ 5.5
|
* g++ 5.5
|
||||||
* g++ 4.9
|
* g++ 4.9
|
||||||
* g++ 4.8
|
* g++ 4.8
|
||||||
- Windows
|
- Windows
|
||||||
|
Reference in New Issue
Block a user