C++ Logo


Advanced search

Re: Fwd: about reusing source_location type

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Wed, 4 Aug 2021 19:17:07 +0100
On Wed, 4 Aug 2021 at 16:40, Jason McKesson via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> On Wed, Aug 4, 2021 at 10:28 AM Jordi Vilar via Std-Discussion
> > Is there any deep reason for not having a constructor allowing
> > initializing all four fields?
> A `source_location` should either be a valid location in the source
> (aka: the return value of some call to `current()`), or it should be
> nonsense data.

Why? It'd be useful to be able to refer to locations referred to in a
std::stacktrace_entry, or in a program other than the current program being
executed - when writing e.g. a compiler, an IDE, or some other development
tool. I realize that this isn't currently allowed by the API, but that
doesn't in itself make it a bad idea.

It should *never* store values manufactured by user
> code.

The #line directive allows the user to store arbitrary values for
file_name() and line() at compile time.

Received on 2021-08-04 13:17:20