Accessing a function, defined in the encapsulating structure, in the nested template function
14:48 13 Feb 2026

I have this very simplified demo.

How can I access in the FAEWE_LOG_THREAD() function/constructor the function getInstrumentsId() defined in the struct LoggingClass? The function returns the value of the member m_instrumentsId in the Faewe class.

#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 << "InstrumentsId from LoggingClass:" << ???
            //////////////////////////////////////////////////////////////
        }
    
        FAEWE_LOG_THREAD( const bool fallbackToServer, const char * formatString, Ts &&... logArguments,
                const std::source_location & sourceLocation = std::source_location::current() )
        {
        }
        
    };
    
    template 
    FAEWE_LOG_THREAD( const char *, Ts &&... ) -> FAEWE_LOG_THREAD;

    template 
    FAEWE_LOG_THREAD( const bool, const char *, Ts &&... ) -> 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 << "InstrumentsId in LoggingClass=" << this->getInstrumentsId() << std::endl;
}

auto main() -> int
{
    Faewe faewe;
    faewe.demo();

    return 0;
}
c++ templates