I am trying to do the following: get the address of a member function from a class locally defined inside the function.
class ConnectionBase
{
};
template class<EventType, SinkType>
class ConnectionImpl : public ConnectionBase
{
public:
typedef void (SinkType::*EventCallback)(EventType const&);
};
template<class EventType>
class Source
{
template <class SinkType>
boost::shared_ptr<ConnectionBase> setupCallback(typename ConnectionImpl<EventType, SinkType>::EventCallback func, SinkType* sink)
{
}
};
class SomeClass
{
public:
void someFunction(int const& event){}
}
class SomeUnitTest
{
public:
void someTest()
{
class NestedClass
{
public:
void someFunction(int const& event){}
};
NestedClass nc;
setupCallback<int, NestedClass>(&NestedClass::someFunction, &nc);
setupCallback<int, NestedClass>(&SomeUnitTest::someTest::NestedClass::someFunction, &nc);
setupCallback<int, NestedClass>(&SomeUnitTest::someTest()::NestedClass::someFunction, &nc);
SomeClass sc;
setupCallback<int, SomeClass>(&SomeClass::someFunction, &sc);
}
};
Try # 2 and # 3 to completely confuse GCC, it doesn't know what I'm trying to do. Try # 1 produces a more useful error message saying that no setupCallback exists, which takes the form "setupCallback (void (SomeUnitTest :: someTest () :: NestedClass :: SomeFunction :: *), etc.) This is how it was born attempt number 3.
I cannot find much information about classes defined inside a function, does anyone know the correct syntax for this, and maybe there is a resource discussing this issue?
, , , , , . , , , , , , : http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=420
:
setupCallback(),
# 2:
"" "". ββ setupCallback.
# 3: . .