Re: [Development] C++20 goodies (was: Using '#pragma once' instead of include guards?)

2022-10-13 Thread Richard Weickelt




Nice.  I'm a bit surprised file_name() returns a char* rather than a
std::filesystem::path, but it'll do.  It's also nice to see
source_location has a function_name() that can finally unify the
disparate ways of getting that information.



The advantages are for instance that file_name() does even work on tiny bare 
metal targets without heap. It can be processed in constexpr at 
compile-time. const char* gives the user a lot of freedom to decide what to 
pay for.

___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] C++20 goodies (was: Using '#pragma once' instead of include guards?)

2022-10-13 Thread Thiago Macieira
On Wednesday, 12 October 2022 02:04:06 PDT Edward Welbourne via Development 
wrote:
> Henry Skoglund (11 October 2022 22:18) wrote:
> > Sometime in the far future when Qt requires c++20 things might
> > improve: we could use std::source_location::filename
> > (https://en.cppreference.com/w/cpp/utility/source_location/file_name )
> 
> Nice.  I'm a bit surprised file_name() returns a char* rather than a
> std::filesystem::path, but it'll do.  It's also nice to see
> source_location has a function_name() that can finally unify the
> disparate ways of getting that information.

That's because of what I said: the standard can't agree on what a file is 
during compilation. The compiler need not be running on a C++ hosted system, 
or on a system that has a file system in the first place, so use of 
std::filesystem to represent source code is technically "wrong".

> More things to look forward to when we eventually get to C++20 ...

For me, the one I'm most looking for is also one of the simplest: std::span. 
In this PR to another project, you can see my removing of its replacement:

https://github.com/opendcdiag/opendcdiag/pull/165/commits

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering



___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] C++20 goodies (was: Using '#pragma once' instead of include guards?)

2022-10-12 Thread Edward Welbourne via Development
Henry Skoglund (11 October 2022 22:18) wrote:
> Sometime in the far future when Qt requires c++20 things might
> improve: we could use std::source_location::filename
> (https://en.cppreference.com/w/cpp/utility/source_location/file_name )

Nice.  I'm a bit surprised file_name() returns a char* rather than a
std::filesystem::path, but it'll do.  It's also nice to see
source_location has a function_name() that can finally unify the
disparate ways of getting that information.

More things to look forward to when we eventually get to C++20 ...

Eddy.
___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development