dimanche 29 décembre 2019

Multiline Formatting of else Statements in C/C++ without Braces

I am rewriting some C++ code, I have the following

if (ConfidenceBias.value > 0) *normalInfo = tree.setDataField(NormalSigs(), *samples, *sampleData, density, pointWeightSum, ConversionAndBiasFunction);
else *normalInfo = tree.setDataField(NormalSigs(), *samples, *sampleData, density, pointWeightSum, ConversionFunction); ThreadPool::Parallel_for(0, normalInfo->size(), [&](unsigned int, size_t i) { (*normalInfo)[i] *= (Real)-1.; });

I assume that this is equivalent to

if (ConfidenceBias.value > 0) 
{
    *normalInfo = tree.setDataField(NormalSigs(), *samples, *sampleData, density, pointWeightSum, ConversionAndBiasFunction);
}
else 
{
    *normalInfo = tree.setDataField(NormalSigs(), *samples, *sampleData, density, pointWeightSum, ConversionFunction);  
}

ThreadPool::Parallel_for(0, normalInfo->size(), [&](unsigned int, size_t i) { (*normalInfo)[i] *= (Real)-1.; });

but there is a slight conern that the compiler is interpreting the original as

if (ConfidenceBias.value > 0) 
{
    *normalInfo = tree.setDataField(NormalSigs(), *samples, *sampleData, density, pointWeightSum, ConversionAndBiasFunction);
}
else 
{
    *normalInfo = tree.setDataField(NormalSigs(), *samples, *sampleData, density, pointWeightSum, ConversionFunction);  
    ThreadPool::Parallel_for(0, normalInfo->size(), [&](unsigned int, size_t i) { (*normalInfo)[i] *= (Real)-1.; });
}

I cannot find a reference to what the VSVC compiler does anywhere. Which is it?

Aucun commentaire:

Enregistrer un commentaire