    #include <cstdio>
    #include <iostream>

    template<size_t BufSize, typename... Args>
    int strprintf(char(&buf)[BufSize], const char* fmt, Args&&... args)
    {
        static_assert(BufSize > 0, "Buffer too small");
        static_assert(BufSize < (1 << 31), "Buffer too large");
        return snprintf(buf, BufSize, fmt, std::forward<Args>(args)...);
    }

    int main() {
        char buf[16];
        int printed = strprintf(buf, "hello world %s so long", "oversized load");
        std::cout << buf << "\n";
    }
