40 void FunctorTest::testBoostOptionalFMap ()
42 boost::optional<int> value { 2 };
43 const auto& fmapped =
Fmap (value, [] (
int val) {
return QString::number (val); });
44 QCOMPARE (boost::optional<QString> {
"2" }, fmapped);
47 void FunctorTest::testBoostOptionalFMapEmpty ()
49 boost::optional<int> value;
50 const auto& fmapped =
Fmap (value, [] (
int val) {
return QString::number (val); });
51 QCOMPARE (boost::optional<QString> {}, fmapped);
54 void FunctorTest::testIsFunctorTrue ()
56 static_assert (
IsFunctor<boost::optional<int>> (),
"test failed");
59 void FunctorTest::testIsFunctorFalse ()
61 static_assert (!IsFunctor<int> (),
"test failed");
constexpr bool IsFunctor()
Checks whether the given type has a Functor instance for it.
FmapResult_t< T, F > Fmap(const T &functor, const F &function)
Apply the function f to the elements in functor.