summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hana/example/optional/searchable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/hana/example/optional/searchable.cpp')
-rw-r--r--src/boost/libs/hana/example/optional/searchable.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/boost/libs/hana/example/optional/searchable.cpp b/src/boost/libs/hana/example/optional/searchable.cpp
new file mode 100644
index 000000000..e95d451af
--- /dev/null
+++ b/src/boost/libs/hana/example/optional/searchable.cpp
@@ -0,0 +1,27 @@
+// Copyright Louis Dionne 2013-2017
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
+
+#include <boost/hana/all_of.hpp>
+#include <boost/hana/assert.hpp>
+#include <boost/hana/equal.hpp>
+#include <boost/hana/find_if.hpp>
+#include <boost/hana/integral_constant.hpp>
+#include <boost/hana/mod.hpp>
+#include <boost/hana/not_equal.hpp>
+#include <boost/hana/optional.hpp>
+namespace hana = boost::hana;
+
+
+auto odd = [](auto x) {
+ return x % hana::int_c<2> != hana::int_c<0>;
+};
+
+BOOST_HANA_CONSTANT_CHECK(hana::find_if(hana::just(hana::int_c<3>), odd) == hana::just(hana::int_c<3>));
+BOOST_HANA_CONSTANT_CHECK(hana::find_if(hana::just(hana::int_c<2>), odd) == hana::nothing);
+BOOST_HANA_CONSTANT_CHECK(hana::find_if(hana::nothing, odd) == hana::nothing);
+
+BOOST_HANA_CONSTANT_CHECK(hana::all_of(hana::just(hana::int_c<3>), odd));
+BOOST_HANA_CONSTANT_CHECK(hana::all_of(hana::nothing, odd));
+
+int main() { }