summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-03-25 09:33:38 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-03-25 09:33:38 +0100
commit944dafbf0ab104fabad8da471d947f2da8584e15 (patch)
treeeadfae789836ae2d3435aa6726179676f7152951 /examples
parente101c9a779a8df023973be161453994fe2aa6346 (diff)
feat(stdx.hpp): add forwardwing since we're taking by universal
reference here. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt8
-rw-r--r--examples/must_pass.cc40
-rw-r--r--examples/str_checksum.cc40
3 files changed, 44 insertions, 44 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 0ba445b..0075ad5 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -2,11 +2,11 @@
cmake_minimum_required(VERSION 3.15...3.31)
project(
- StrCheckusm
+ MustPass
VERSION 1.0
LANGUAGES CXX)
-add_executable(StrCheckusm str_checksum.cc)
+add_executable(MustPass must_pass.cc)
-set_property(TARGET StrCheckusm PROPERTY CXX_STANDARD 20)
-target_include_directories(StrCheckusm PUBLIC ../lib)
+set_property(TARGET MustPass PROPERTY CXX_STANDARD 20)
+target_include_directories(MustPass PUBLIC ../lib)
diff --git a/examples/must_pass.cc b/examples/must_pass.cc
new file mode 100644
index 0000000..377f8bb
--- /dev/null
+++ b/examples/must_pass.cc
@@ -0,0 +1,40 @@
+/*
+ string checksum example
+ written by Amlal El Mahrouss.
+ licensed under GPL-2 license
+ */
+
+#include <stdx.hpp>
+#include <string>
+
+static const char do_hash(const std::string& in)
+{
+ int hash = 0;
+
+ for (long index = 0; index < in.size(); ++index)
+ {
+ hash += in[index];
+ }
+
+ return hash;
+}
+
+static auto do_some(const std::string recv_data, const std::string check_data)
+{
+ const int hash_to_check = do_hash(check_data); /* here we assume this should match opt_hash */
+ const int opt_hash = do_hash(recv_data); /* we assume that the hash is correct */
+
+ auto opt = stdx::opt(stdx::eval_eq(hash_to_check, opt_hash)); /* do the compute */
+ return opt;
+}
+
+/* finally test it */
+int main(int argc, char** argv)
+{
+ // ... let's assume we fetch data from network...
+
+ auto opt = do_some("Ohio", "Ohio");
+ opt.expect("Checksum failed, Ohio isn't Ohio!");
+
+ return 0;
+}
diff --git a/examples/str_checksum.cc b/examples/str_checksum.cc
deleted file mode 100644
index a4d5e87..0000000
--- a/examples/str_checksum.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- string checksum example
- written by Amlal El Mahrouss.
- licensed under GPL-2 license
- */
-
-#include <stdx.hpp>
-#include <string>
-
-static const char do_hash(const std::string& in)
-{
- int hash = 0;
-
- for (long index = 0; index < in.size(); ++index)
- {
- hash += in[index];
- }
-
- return hash;
-}
-
-static auto do_some(const std::string recv_data, const std::string check_data)
-{
- const int hash_to_check = do_hash(check_data); /* here we assume this should match opt_hash */
- const int opt_hash = do_hash(recv_data); /* we assume that the hash is correct */
-
- auto opt = stdx::opt(stdx::eval_eq(hash_to_check, opt_hash)); /* do the compute */
- return opt;
-}
-
-/* finally test it */
-int main(int argc, char** argv)
-{
- // ... let's assume we fetch data from network...
-
- auto opt = do_some("Michigan", "Ohio");
- opt.expect("Checksum failed, Michigan isn't Ohio!");
-
- return 0;
-}