google / benchmark

A microbenchmark support library
Apache License 2.0
8.69k stars 1.59k forks source link

Fix examples in user guide using deprecated `DoNotOptimize`-API #1568

Closed mjacobse closed 1 year ago

mjacobse commented 1 year ago

The const-reference API to DoNotOptimize was deprecated with #1493. Some examples in the user guide are using exactly that deprecated interface. This fixes that by passing non-const lvalues instead. Fixes #1566

I tried to provide a brief comment explaining why a copy is passed to DoNotOptimize. I opted to do so only in the section that addresses the DoNotOptimize feature directly, to not clutter the examples that highlight other aspects too much. I do wonder whether a more elaborate explanation in the "Preventing Optimization" section might be warranted, but perhaps that is for another PR?

dmah42 commented 1 year ago

thanks!