We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 787b561 commit 0b892feCopy full SHA for 0b892fe
cpp/17.cpp
@@ -537,6 +537,15 @@ void variant_demo()
537
assert(visit(inc, (variant<int>)1) == 2);
538
}
539
540
+void optional_demo()
541
+{
542
+ optional<int> i = make_optional(1);
543
+ assert(i.has_value());
544
+ assert(i.value() == 1);
545
+ i = nullopt;
546
+ assert(i.value_or(2) == 2);
547
+}
548
+
549
void clamp_demo()
550
{
551
static_assert(__cpp_lib_clamp);
@@ -601,6 +610,7 @@ int main()
601
610
threads_17();
602
611
map_demo();
603
612
variant_demo();
613
+ optional_demo();
604
614
clamp_demo();
605
615
dynamic_memory_17();
606
616
string_view_demo();
0 commit comments