From 3ab1012ea8c55f82812b5998fd6b4fdf53dea70e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 14 Apr 2025 14:00:44 +0200 Subject: Improved C++ API and added info to README --- cpp/examples/move_convert.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 cpp/examples/move_convert.cpp (limited to 'cpp/examples/move_convert.cpp') 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 @@ +/* A simple example showing how to move a cube and print it in H48 format. */ + +#include "../nissy.h" +#include + +int main() { + nissy::cube c; + if (!c.move("R' U' F").ok()) { + std::cout << "Error moving the cube!" << std::endl; + return 1; + } + + auto string_or_error = c.to_string("H48"); + if (std::holds_alternative(string_or_error)) { + std::cout << "Error converting cube!" << std::endl; + return 1; + } + + auto str = std::get(string_or_error); + std::cout << "Cube in H48 format after R' U' F:" << std::endl + << str << std::endl; + + return 0; +} -- cgit v1.3