Skip to content
This repository was archived by the owner on Jan 29, 2026. It is now read-only.

Commit e0846a5

Browse files
authored
Update sample code for basic_facade_builder::add_facade (#158)
1 parent 35064e6 commit e0846a5

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

samples/basic_facade_builder/add_facade.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct StringDictionary : pro::facade_builder
2626
::build {};
2727

2828
struct MutableStringDictionary : pro::facade_builder
29-
::add_facade<StringDictionary>
29+
::add_facade<StringDictionary, true>
3030
::add_convention<MemEmplace, void(std::size_t key, std::string value)>
3131
::build {};
3232

@@ -42,9 +42,11 @@ int main() {
4242
p1->emplace(123, "lalala");
4343
auto p2 = p1; // Performs a deep copy
4444
p2->emplace(456, "trivial");
45+
pro::proxy<StringDictionary> p3 = std::move(p2); // Performs an upward conversion from an rvalue reference
4546
std::cout << p1->size() << "\n"; // Prints "1"
4647
std::cout << p1->at(123) << "\n"; // Prints "lalala"
47-
std::cout << p2->size() << "\n"; // Prints "2"
48-
std::cout << p2->at(123) << "\n"; // Prints "lalala"
49-
std::cout << p2->at(456) << "\n"; // Prints "trivial"
48+
std::cout << std::boolalpha << p2.has_value() << "\n"; // Prints "false" because it is moved
49+
std::cout << p3->size() << "\n"; // Prints "2"
50+
std::cout << p3->at(123) << "\n"; // Prints "lalala"
51+
std::cout << p3->at(456) << "\n"; // Prints "trivial"
5052
}

0 commit comments

Comments
 (0)