У меня есть очень упрощенная демонстрация.
Как я могу получить доступ в функции/конструкторе FAEWE_LOG_THREAD() к функции getInstrumentsId(), определенной в структуре LoggingClass? Функция возвращает значение члена m_instrumentsId в классе Faewe.
#include
#include
template
struct LoggingClass
{
protected:
template
struct FAEWE_LOG_THREAD
{
FAEWE_LOG_THREAD( const char * formatString, Ts &&... logArguments,
const std::source_location & sourceLocation = std::source_location::current() )
{
//////////////////////////////////////////////////////////////
// How to access defined in LoggingClass?
//std::cout FAEWE_LOG_THREAD;
inline auto getInstrumentsId() -> uint
{
return static_cast(this)->m_instrumentsId; // 73
}
};
class Faewe : protected LoggingClass
{
friend class LoggingClass;
protected:
uint m_instrumentsId {73};
public:
auto demo() -> void;
};
auto Faewe::demo() -> void
{
FAEWE_LOG_THREAD( "Pi=%.3f", 3.141 );
FAEWE_LOG_THREAD( true, "Euler's=%.3f", 2.718 );
std::cout
Подробнее здесь: https://stackoverflow.com/questions/798 ... ested-temp