Or are you looking for a way to specify an explicit template constructor argument list? Possibly with T& reference type?

This would be possible for non-constructor template functions.

 

Currently the standard says as note:

https://timsong-cpp.github.io/cppwp/temp.arg.explicit#8

[Note 4: 

Because the explicit template argument list follows the function template name, and because constructor templates ([class.ctor]) are named without using a function name ([class.qual]), there is no way to provide an explicit template argument list for these function templates.

— end note]


 

 

-----Ursprüngliche Nachricht-----
Von: David wang via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Di 07.05.2024 09:46
Betreff: [std-proposals] Pass derived object by reference to single parameter delegated templated constructors
An: C++ <std-proposals@lists.isocpp.org>;
CC: David wang <wangjufan@gmail.com>;
On Mon, 6 May 2024 10:18:35 -0400  Jason McKesson via Std-Proposals
<std-proposals@lists.isocpp.org> wrote:
>This is way too special-case to implement. It's ultimately on the user
>to prevent this from happening. `base`'s constructor uses template
>argument deduction. That function takes its parameter by value. If you
>use template argument deduction on such a function and pass it a type
>which is a reference, it will copy the parameter. This *needs* to be a
>hard-and-fast rule.
 
It is a special case. It is a conflict between rule and best practices.
But It is not the user's fault. Rules and practices may change or be refined by us.

 

-- 
 Std-Proposals mailing list
 Std-Proposals@lists.isocpp.org
 https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals