diff --git a/final/eventloop/monitor.h b/final/eventloop/monitor.h index 40d198db..ffcecff9 100644 --- a/final/eventloop/monitor.h +++ b/final/eventloop/monitor.h @@ -164,12 +164,12 @@ inline auto Monitor::getFileDescriptor() const -> int //---------------------------------------------------------------------- template -inline auto Monitor::getUserContext() const -> clean_fdata_t& +auto Monitor::getUserContext() const -> clean_fdata_t& { - auto empty = static_cast(0); + static T empty_lvalue = T{}; return user_context ? static_cast>&>(*user_context).get() - : empty; + : empty_lvalue; } //---------------------------------------------------------------------- diff --git a/test/eventloop-monitor-test.cpp b/test/eventloop-monitor-test.cpp index a23b969c..eca234df 100644 --- a/test/eventloop-monitor-test.cpp +++ b/test/eventloop-monitor-test.cpp @@ -569,6 +569,11 @@ void EventloopMonitorTest::noArgumentTest() CPPUNIT_ASSERT ( m.getUserContext() == nullptr ); CPPUNIT_ASSERT ( m.getUserContext() == 0 ); CPPUNIT_ASSERT ( m.getUserContext() == nullptr ); + CPPUNIT_ASSERT ( m.getUserContext() == 0.0 ); + CPPUNIT_ASSERT ( m.getUserContext() == nullptr ); + CPPUNIT_ASSERT ( m.getUserContext() == finalcut::FPoint() ); + CPPUNIT_ASSERT ( m.getUserContext() == finalcut::FPoint(0, 0) ); + CPPUNIT_ASSERT ( m.getUserContext() != finalcut::FPoint(1, 2) ); CPPUNIT_ASSERT ( m.getUserContext() == 0 ); CPPUNIT_ASSERT ( m.getUserContext() == nullptr ); CPPUNIT_ASSERT ( ! m.isActive() );