Skip to content

Commit

Permalink
serge-sans-paille#105 Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Moran committed Nov 6, 2020
1 parent 1dba1a2 commit cf300dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(frozen.examples.srcs enum_to_string enum_to_string_hash pixel_art static_assert)
set(frozen.examples.srcs enum_to_string enum_to_string_hash pixel_art static_assert value_modification)

if ("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang")
list(APPEND frozen.examples.srcs html_entities_map)
Expand Down
28 changes: 28 additions & 0 deletions examples/value_modification.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <frozen/set.h>
#include <frozen/string.h>
#include <frozen/unordered_map.h>
#include <iostream>


int main() {
frozen::unordered_map<frozen::string, int, 2> fruits = {
{"n_apples", 0},
{"n_pears", 0},
};

std::cout << fruits.at("n_apples") << std::endl;
std::cout << fruits.at("n_pears") << std::endl;

fruits.at("n_apples") = 10;
fruits.at("n_pears") = fruits.at("n_apples") * 2;

std::cout << fruits.at("n_apples") << std::endl;
std::cout << fruits.at("n_pears") << std::endl;

auto found = fruits.find("n_oranges");
if (found == fruits.end()) {
std::cout << "no oranges, as expected" << std::endl;
}

auto range = fruits.equal_range("n_oranges");
}

0 comments on commit cf300dd

Please sign in to comment.