commit 98dfdfc2aaa92bacdc94fedc433931cb3ea66a0a
parent ba4e25810e0b845fe0488bc504bf3ab5bd1f3824
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Sat, 4 May 2024 18:36:31 +0200
Added .gitignore; C++ example clean up; example compile script clean up
Diffstat:
6 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,3 @@
+cube.o
+example/a.out
+example/example.o
diff --git a/cube.o b/cube.o
Binary files differ.
diff --git a/example/a.out b/example/a.out
Binary files differ.
diff --git a/example/compile.sh b/example/compile.sh
@@ -1 +1,6 @@
-g++ example.cpp ../cube.o
+#!/bin/sh
+
+compiler="$((g++ -v 2>/dev/null && echo "g++") ||\
+ (clang++ -v 2>/dev/null && echo "clang++"))"
+
+${compiler} -std=c++14 example.cpp ../cube.o
diff --git a/example/example.cpp b/example/example.cpp
@@ -6,18 +6,18 @@ extern "C" {
#include "../cube.h"
}
-cube_t apply_alg(cube_t cube, std::vector<move_t> *moves) {
- auto ret = cube;
+cube_t apply_alg(cube_t cube, std::vector<move_t>& moves) {
+ auto ret {cube};
- for (auto m : *moves)
+ for (auto m : moves)
ret = cube_move(ret, m);
return ret;
}
int main() {
- auto cube = cube_new();
- auto moves = new std::vector<move_t> { R, U, R3, U3 };
+ auto cube {cube_new()};
+ std::vector<move_t> moves { R, U, R3, U3 };
char cstr[500];
std::cout << "The solved cube looks like this in H48 notation:\n";
diff --git a/example/example.o b/example/example.o
Binary files differ.