Q:

std::experimental::source_location implementation in visual studio

A reasonably conforming version of std::experimental::source_location can be implemented in gcc with __builtin_FILE(), __builtin_LINE(), etc.  Do similar intrinsics exist in Visual Studio 2017?  Or is there any way to implement std::experimental::source_location in Visual Studio 2017?

A:

Unfortunately, at the moment there is no way to properly implement source_location only by means of compiler, so you'll have to use preprocessor and macros like __FILE__, __LINE__ and __FUNCTION__ to feed the location info into the data structure that stores them (what you call source_location).
Having said that, I really do share your pain.
I have been recently developing a small library that adds location data and some other information to the exceptions that get thrown, and there I had to end up with an ugly macro like MY_THROW(Exception(args)) which basically just feeds the values obtained from the aforementioned macros into the function which throws an exception. As terribly-looking as it is, it seems to be the only working option so far.

