Skip to content

Commit

Permalink
Replace "void *" with meaningful type FData
Browse files Browse the repository at this point in the history
  • Loading branch information
gansm committed Sep 15, 2023
1 parent 591d544 commit 13194bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions final/eventloop/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ inline auto Monitor::getFileDescriptor() const -> int

//----------------------------------------------------------------------
template <typename T>
inline auto Monitor::getUserContext() const -> clean_fdata_t<T>&
auto Monitor::getUserContext() const -> clean_fdata_t<T>&
{
auto empty = static_cast<T>(0);
static T empty_lvalue = T{};
return user_context
? static_cast<FData<clean_fdata_t<T>>&>(*user_context).get()
: empty;
: empty_lvalue;
}

//----------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions test/eventloop-monitor-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,11 @@ void EventloopMonitorTest::noArgumentTest()
CPPUNIT_ASSERT ( m.getUserContext<int*>() == nullptr );
CPPUNIT_ASSERT ( m.getUserContext<long>() == 0 );
CPPUNIT_ASSERT ( m.getUserContext<long*>() == nullptr );
CPPUNIT_ASSERT ( m.getUserContext<double>() == 0.0 );
CPPUNIT_ASSERT ( m.getUserContext<double*>() == nullptr );
CPPUNIT_ASSERT ( m.getUserContext<finalcut::FPoint>() == finalcut::FPoint() );
CPPUNIT_ASSERT ( m.getUserContext<finalcut::FPoint>() == finalcut::FPoint(0, 0) );
CPPUNIT_ASSERT ( m.getUserContext<finalcut::FPoint>() != finalcut::FPoint(1, 2) );
CPPUNIT_ASSERT ( m.getUserContext<std::size_t>() == 0 );
CPPUNIT_ASSERT ( m.getUserContext<std::size_t*>() == nullptr );
CPPUNIT_ASSERT ( ! m.isActive() );
Expand Down

0 comments on commit 13194bd

Please sign in to comment.