On Mon, Aug 10, 2026 at 8:48 AM John Ericson <[email protected]> wrote:
>
> On Mon, Aug 10, 2026, at 3:06 AM, Andrea Pinski wrote:
> > Do we have a callback that needs some other data passed to it?
> > If not then I would not make this a template and just make the
> > callback argument a function type `void (*)(const char*)`.
>
> You are correct that the function arguments in this patch don't need to
> capture anything, but (as you note in the next patch's reply) the
> function arguments in subsequent patches do.
>
> In the interests of making patches stand alone, however, I would still
> be happy to make this patch use C function pointers, if you prefer,
> switching back to C++ templates only in patch 2 where the non-empty
> captures motivate it.

I am still not a fan of this being a typeless argument; lambdas being
a "typeless" argument
Can we change this into say:
```
template<typename T>
static void
for_each_env_path (const char *value, char *(*callback)(const char*, T
*), T *data)
```
Instead?
Yes that means not using lambdas but I think it is more explicit and
yes it is not "C++ style". It also forces captures to be much more
explicit.
Yes it means structs need to be written out.
But it is typesafe and moreover it is easier to figure out what
arguments should be passed to the callback. (I wish C++ syntax for
callbacks and lambdas allowed for this better).


>
> John

Reply via email to