C++ Weekly - Ep 258 - The Awesome Power of C++20's std::source_location

preview_player
Показать описание
☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟

T-SHIRTS AVAILABLE!

WANT MORE JASON?

SUPPORT THE CHANNEL

GET INVOLVED

JASON'S BOOKS

► C++23 Best Practices

► C++ Best Practices

JASON'S PUZZLE BOOKS

► Object Lifetime Puzzlers Book 1

► Object Lifetime Puzzlers Book 2

► Object Lifetime Puzzlers Book 3

► Copy and Reference Puzzlers Book 1

► Copy and Reference Puzzlers Book 2

► Copy and Reference Puzzlers Book 3

► OpCode Puzzlers Book 1


RECOMMENDED BOOKS

AWESOME PROJECTS

O'Reilly VIDEOS

Рекомендации по теме
Комментарии
Автор

Wow.. the fact it tells you the template arg names and param types is pretty cool. C++ is definitely becoming very very useful and easier to use at higher level.

fredhair
Автор

For anyone wondering: If used with inline/constexpr/consteval, it still acts as if it was it's own function.

nikitademodov
Автор

This is amazing, the amount of introspection from the compiler here can also help with understanding the language! The actual values that the source_location's components provide are implementation-defined. Hopefully, other compilers implement it in similar ways!

blazkranjc
Автор

00:58 ah yes, your Compiler Supporter setup

humm
Автор

This is very nice. A cross platform way to get a demangled stack trace should be the next logical feature to get. ^_^

DamianReloaded
Автор

It also has interesting applications when used as a default member initializer (then it refers to the constructor that the surrounding object was created by)

n-ds
Автор

This default parameter to log is all nice and good, but I reckon most log functions want variadic argument list at the end like: auto ... args to print out. Sure you could probably pass the source_location::current() as a template parameter, but that's a potentially a lot of function stamping. Anyone got any nice ideas except reverting to a macro again?

CallumPooleProgrammer
Автор

Amazing, this has been on my wishlist since forever!

kodref
Автор

Being tortured by macros encapsulating Boost logging, this seems really useful. An example with iostream logging would be useful.

miltiadiskoutsokeras
Автор

I have been waiting for this!! Thanks for the video!

pitomator
Автор

If it's demangled and on GCC it's probably because it uses the cxa::demangle function thing that I stumbled upon once, which is useful. It seems to have been in GCC since forever too.

simonfarre
Автор

Just hope Clang and MSVC++ provide equally useful information in their implementations of source_location.

jessetowner
Автор

Overload new and delete with some of this trickery; make your own simple memory profiler with nice logging? I'm pretty outdated with cpp, haven't had time to keep up witg it recently but would this be useful with the new modules?

fredhair
Автор

I've been waiting for this since 1992 when I first learnt c++ 😮🙄😊

RichardEricCollins
Автор

seems amazing!
I'm not sure about the usefulness of the column option, when will that be helpful?

benjaminshinar
Автор

Does anybody have any idea when this will be supported in Visual Studio?

ruadeil_zabelin
Автор

Was getting filename in the code possible before source_location in C++?

Автор

What does "reflection" mean in this context?

AlfW
Автор

This is the SFINAE replacement we needed :P . A consteval function checks the template substitution and based on that specialize functions using 'if constexpr'.

indrajitbanerjee
Автор

I am surprised to see that source_location::file_name() and return a char*. As far as I know, source file names and function names may use unicode characters. How does this fit together? Why doesn't the standard use wchar_t*?

hstrauss