Also, when one has problems with complex templates, sometimes the answer is to make more use of auto, so if you have removed the trailing return type and just use auto, and it works, why not go with that?
godbolt using VS doesn't compile. So possibly a bug with VS2022. I've had issues with VS concepts previously - where godbolt compiles but VS doesn't. Twice MS agreed it was a problem and fixed it and once stated they adhered to the standard and gcc had an 'extension'.
@JUANDENT I suggest you raise this as an issue with MS (VS/help/SendFeedback/reportaproblem ) and include the godbolt link.