I'm experimenting writing functions which use new and delete on passed pointers, but the function which allocates writes to a text file which file and line the memory was allocated on, and the name of the variable, and the function which deallocates needs to search for the variable name in the text file and then when it finds it, erase the line.
This will make memory leak detection easy as at the end of a program you will have a text file containing the name, file and line of every piece of memory which was not freed. To do this though I will need to pass a the name of the variable into the function, I can't think of a way to do this.
Although it doesn't appear in the standard, the preprocessor often provides __FILE__ and __LINE__ that give the file name and line number of a line in a file. These are often used for exactly what you might need them for.
There isn't a standard way of determining the function name.