On Thursday, 25 January 2018 at 21:33:10 UTC, Simen Kjærås wrote:
On Thursday, 25 January 2018 at 19:54:55 UTC, H. S. Teoh wrote:
In fact, if the standard implementation of opHeadMutable is basically the same across all types (or most types), it could even be provided as a mixin template in the library, then all you have to do is to `mixin headMutable` or something along those lines, and off you go.

I believe this should be possible

I'm wrong, of course. Consider these two types:

struct S(T) {
    T payload;
}
struct U(T) {
    T[] payload;
}

Clearly, a mixin would have problems with at least one of these. In the general case, the correlation between template parameters and member types can be arbitrarily complex, so a general solution is impossible, but even with this simple example there are problems.

I wrote up a more formal description of what I'm suggesting:

https://gist.github.com/Biotronic/c6eefeb9796309360a5e8696d91d924d

--
  Simen

Reply via email to