ARTICLE AD BOX
This has nothing to do with structured bindings. A plain const int causes the same warning:
#include <benchmark/benchmark.h> int main() { const int x = 42; benchmark::DoNotOptimize(x); // warning: 'DoNotOptimize<int>' is deprecated: The const-ref version of this method can permit undesired compiler optimizations in benchmarks [-Wdeprecated-declarations] }In general, it's impossible to distinguish between a non-reference variable and a reference to the same type (other than with decltype, which is something a macro could do, and DoNotOptimize isn't one).
But to answer your question, a structured binding creates one hidden variable, as if [...] was replaced with a variable name.
So auto const [a, b] = ToBind{}; becomes auto const hidden = ToBind{};, which is same as const ToBind hidden; in your case.
The names in brackets then become semi-magical references to the members of that hidden variable. Some of their magical properties include not reporting a reference type to decltype, like real references do. (And I can't think of any other magical properties in the current standard.)
But since, again, it's impossible to distinguish between a reference and a non-reference without decltype, the magic of those references doesn't matter in most cases.
