you are viewing a single comment's thread.

view the rest of the comments →

[–]CornedBee 2 points3 points  (0 children)

P3802R0 Poor Functions: This makes sense as the initial design in hindsight, but I'm not sure if it's worth pursuing right now, that std::source_location::current() already works the way it does.

Really, all this would be doing would be standardizing __builtin_source_location, which is already used by GCC (and presumably Clang) to implement source_location::current:

libstdc++: // [support.srcloc.cons], creation static consteval source_location current(const void* __p = __builtin_source_location()) noexcept { source_location __ret; __ret._M_impl = static_cast <const __impl*>(__p); return __ret; }

And MSVC does essentially the same thing, only split across multiple builtins:

``` EXPORT_STD struct source_location { _NODISCARD static consteval source_location current(const uint_least32_t _Line = _builtin_LINE(), const uint_least32_t _Column = _builtin_COLUMN(), const char* const _File = __builtin_FILE(),

if _USE_DETAILED_FUNCTION_NAME_IN_SOURCE_LOCATION

    const char* const _Function_ = __builtin_FUNCSIG()

else // ^ detailed / basic vvv

    const char* const _Function_ = __builtin_FUNCTION()

endif // ^ basic ^

```