AFAIK you can't request C++ compilers to compile just one function and nothing
else. The "compilation unit" of C++ is one file with everything that it does #include
preprocessed into it. But if you want to make such a tool then feel free. Lot of C++
compilers (including clang and g++) are open source.