MCPcopy Create free account
hub / github.com/davisking/dlib / test_optional_int_constexpr_monads

Function test_optional_int_constexpr_monads

dlib/test/optional.cpp:296–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294// ---------------------------------------------------------------------------------------------------
295
296 void test_optional_int_constexpr_monads()
297 {
298 constexpr dlib::optional<int> o1{42};
299
300 {
301 struct callback
302 {
303 constexpr auto operator()(int i) {return dlib::optional<long>{i}; };
304 };
305
306 constexpr auto res = o1.and_then(callback{});
307
308 static_assert(std::is_same<std::decay_t<decltype(res)>, dlib::optional<long>>::value, "bad map");
309 static_assert(*res == 42, "bad");
310 DLIB_TEST(*res == 42);
311 }
312 }
313
314// ---------------------------------------------------------------------------------------------------
315

Callers 1

perform_testMethod · 0.85

Calls 1

and_thenMethod · 0.80

Tested by

no test coverage detected