Date: Thu, 10 Apr 2025 22:22:09 +0100
On Thu, Apr 10, 2025 at 3:03 PM Ell wrote:
>
> As already been said, this creates more problems than it solves, but if
> you *did* want something like this, why limit it to forwarding
> references? Why not allow any variable to be moved upon last use
> (basically implicit-move on steroids)?
You mean something like the following?
extern string Some_Library_Function(void); // defined in a shared
library binary file
template<typename T> requires is_same_v< string, remove_cvref_t<T> >
void LibFunc1(T &&arg) { /* Do something */ }
template<typename T> requires is_same_v< string, remove_cvref_t<T> >
void LibFunc2(T &&arg) { /* Do something */ }
template<typename T> requires is_same_v< string, remove_cvref_t<T> >
void LibFunc3(T &&arg) { /* Do something */ }
int main(void)
{
string s = Some_Library_Function();
string &&&ss = s;
LibFunc1(s2);
LibFunc2(s2);
LibFunc3(s2); // This one is automatically forwarded
}
>
> As already been said, this creates more problems than it solves, but if
> you *did* want something like this, why limit it to forwarding
> references? Why not allow any variable to be moved upon last use
> (basically implicit-move on steroids)?
You mean something like the following?
extern string Some_Library_Function(void); // defined in a shared
library binary file
template<typename T> requires is_same_v< string, remove_cvref_t<T> >
void LibFunc1(T &&arg) { /* Do something */ }
template<typename T> requires is_same_v< string, remove_cvref_t<T> >
void LibFunc2(T &&arg) { /* Do something */ }
template<typename T> requires is_same_v< string, remove_cvref_t<T> >
void LibFunc3(T &&arg) { /* Do something */ }
int main(void)
{
string s = Some_Library_Function();
string &&&ss = s;
LibFunc1(s2);
LibFunc2(s2);
LibFunc3(s2); // This one is automatically forwarded
}
Received on 2025-04-10 21:22:22