Date: Thu, 10 Apr 2025 19:40:46 +0200
Perhaps in this case, it would be simpler to combine DistributeNode and AssimilateNode into a single function, which expects arg and a bool, and where this condition is encapsulated.
template<typename T>
void DistributeAndOptionallyAssimilateNode(T &&arg, bool assimilate)
{
if (assimilate)
{
DistributeNode( arg );
AssimilateNode( forward<T>(arg) );
}
else
{
DistributeNode( forward<T>(arg) );
}
}
Then ProcessNode is simplified and you can add a new line without too much danger.
template<typename T>
void ProcessNode(T &&arg)
{
NormaliseNode(arg);
DistributeAndOptionallyAssimilateNode(std::forward<T>(arg), NodeManager::mode == NodeManager::ModeAssimilate);
}
With something like relocation, the compiler can give an error, if a relocated variable is reused (after carelessly adding an additional line after relocation).
Would the currently proposed relocation work with function parameters?
-----Ursprüngliche Nachricht-----
Von:Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]>
template<typename T>
bool ProcessNode(T &&arg)
{
NormaliseNode(arg);
if ( NodeManager::mode == NodeManager::ModeAssimilate )
{
DistributeNode( arg );
AssimilateNode( forward<T>(arg) );
}
else
{
DistributeNode( forward<T>(arg) );
}
}
Received on 2025-04-10 17:46:52