Everything goes to a raw string

You can use Strf on CUDA devices but there are some limitations. Naturally, you can’t write to FILE* nor std::string, but you can write raw strings using basic_cstr_writer. So, the kernel — the function marked with __global__ qualifier — receives a char* ( or a pointer to another character type ) where it writes the content, which must later be transferred to the host memory so that the host code can do something useful with it ( like sending to stdout ).

#include <strf.hpp>

__global__ void sample(char* dest, std::size_t dest_size)
{
    strf::cstr_writer writer{dest, dest_size};
    auto print = strf::to(writer);

    print("Hello World!\n");
    print("blah blah blah", 1234, '\n');

    writer.finish();
}

There is a more complete example here. You can also take a look at the the unit tests that run on CUDA device here.

Unsupported features on CUDA devices

The folowing features are not supported on device code: