summaryrefslogtreecommitdiffhomepage
path: root/example/option_example
diff options
context:
space:
mode:
Diffstat (limited to 'example/option_example')
-rw-r--r--example/option_example/example.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/example/option_example/example.cc b/example/option_example/example.cc
index e35f73b..c784dec 100644
--- a/example/option_example/example.cc
+++ b/example/option_example/example.cc
@@ -1,15 +1,23 @@
#include <ocl/crc_hash.hpp>
#include <ocl/print.hpp>
#include <ocl/option.hpp>
-// #include <ocl/is_same.hpp>
+struct invalid_callable {
+ explicit invalid_callable() = default;
+ void operator()(const char* reason)
+ {
+ ocl::detail::throw_runtime_error(BOOST_CURRENT_LOCATION.to_string());
+ }
+};
+
+/// \brief Option Monad example
int main(int argc, char** argv)
{
ocl::option opt{ocl::eval_eq(nullptr, nullptr)};
- opt.expect("is incorrect");
+ opt.expect("option::incorrect");
ocl::option opt2{ocl::eval_eq(argv, nullptr)};
- opt2.expect("is incorrect");
+ opt2.expect<invalid_callable>("option::incorrect");
return 0;
}