aboutsummaryrefslogtreecommitdiff
path: root/cpp/examples/move_convert.cpp
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-14 14:00:44 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-14 14:00:44 +0200
commit3ab1012ea8c55f82812b5998fd6b4fdf53dea70e (patch)
treed18552619a364fcb816d5e2d2331822edd7e2045 /cpp/examples/move_convert.cpp
parent7b8c1e4634784b57bb6223cd780d5c67f5381d43 (diff)
downloadnissy-core-3ab1012ea8c55f82812b5998fd6b4fdf53dea70e.tar.gz
nissy-core-3ab1012ea8c55f82812b5998fd6b4fdf53dea70e.zip
Improved C++ API and added info to README
Diffstat (limited to 'cpp/examples/move_convert.cpp')
-rw-r--r--cpp/examples/move_convert.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/cpp/examples/move_convert.cpp b/cpp/examples/move_convert.cpp
new file mode 100644
index 0000000..11398df
--- /dev/null
+++ b/cpp/examples/move_convert.cpp
@@ -0,0 +1,24 @@
1/* A simple example showing how to move a cube and print it in H48 format. */
2
3#include "../nissy.h"
4#include <iostream>
5
6int main() {
7 nissy::cube c;
8 if (!c.move("R' U' F").ok()) {
9 std::cout << "Error moving the cube!" << std::endl;
10 return 1;
11 }
12
13 auto string_or_error = c.to_string("H48");
14 if (std::holds_alternative<nissy::error>(string_or_error)) {
15 std::cout << "Error converting cube!" << std::endl;
16 return 1;
17 }
18
19 auto str = std::get<std::string>(string_or_error);
20 std::cout << "Cube in H48 format after R' U' F:" << std::endl
21 << str << std::endl;
22
23 return 0;
24}

Generated with cgit - Back to sebastiano.tronto.net