What advantage or difference would there be compared to lambda parameters?

(Except that a constexpr "string" is converted into program code.)

You do not just want to call a callback function at a certain point, but also modify the behaviour of the templated function? E.g. provide a static attribute or not (as you gave as example in another email), ...

Then you are clearly within metaclasses territory. And the proposal only has a chance, if it either merges with all those proposals or clearly and extensively discusses its merits compared to them.

Please read chapter 7 (and the others of) Andrew Sutton: Metaprogramming - Source Code Injection (https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2237r0.pdf)

As you see those ideas are under active deep discussion.
 

-----Ursprüngliche Nachricht-----
Von: Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Mi 30.11.2022 11:09
Betreff: Re: [std-proposals] Extreme Template Parameter Possibilities
An: std-proposals@lists.isocpp.org;
CC: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>;
On Wed, Nov 30, 2022 at 6:47 AM Sebastian Wittmeier via Std-Proposals
<std-proposals@lists.isocpp.org> wrote:
>
>  - leave the function scope by copy-pasting closing braces?

This is a very good example of where things would go way too far.

For example I can close the function body and open a new function as follows:

template<text id, typename T>
T Func(T const &arg)
{
       using namespace id;

       return Transform(arg);   // Might call id::Transform if it exists
}

int main(void)
{
       std::string str;
       Func<"std; return {}; } string Func(string &arg) { arg +=
\"hello\"">(str);
}

So the previous individual template function would become two
functions as follows:

string Func(string const &arg)
{
       using namespace std;
       return {};
}

string Func(string &arg)
{
       arg += "hello";

       return Transform(arg);
}

This of course is way too extreme -- we don't want programmers to have
this level of control.

So how about we restrict a 'text' parameter to being a valid
identifier, i.e. it can contain letters numbers and
underscores but cannot begin with a number. But also allow
double-colons inside it. The following regex would
work to make sure that a 'text' parameter is valid:

       ^(((::){0,1}[_A-z][_A-z0-9]*)+)$

I have give a few sample strings up on the regex101 website (similar
to how GodBolt works), see here:

       https://regex101.com/r/VxB7Xm/1

Perhaps we could also impose the restriction that a 'text' parameter
cannot contain a C++ keyword.

We would need further discussion on whether angle brackets are
allowed, for example:

   Func< "vector<int>" >(obj);
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals