diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 02:13:48 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 02:13:48 +0100 |
| commit | 65a8349aa5526d071b18cd4d42586c46faaa3823 (patch) | |
| tree | f6e2063319ceaaa02f523fb5c289e4f37411a2df /examples/opt/opt.cc | |
| parent | df4ec096491ded6d58b9ee094d6942e3188c2d4a (diff) | |
feat! breaking changes for OCL v1.0.48.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'examples/opt/opt.cc')
| -rw-r--r-- | examples/opt/opt.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/examples/opt/opt.cc b/examples/opt/opt.cc new file mode 100644 index 0000000..75abed4 --- /dev/null +++ b/examples/opt/opt.cc @@ -0,0 +1,45 @@ +/* + String checksum example + Written by Amlal El Mahrouss. + Licensed under the Boost Software License + */ + +#include <logic/opt.hpp> +#include <io/print.hpp> +#include <utility/crc32.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 = ocl::opt(ocl::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... + + ocl::io::println("Testing data..."); + + auto opt = do_some("Ohio", "Ohio"); + opt.expect("Checksum failed, Ohio isn't Ohio!"); + + + return 0; +} |
