Change the enumerate() example to bind the proxy by reference
authorGiuseppe Ottaviano <ott@fb.com>
Wed, 10 Jan 2018 02:44:44 +0000 (18:44 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 10 Jan 2018 02:50:39 +0000 (18:50 -0800)
commit489eeb1c2459073d09151b359109369e3f395d06
tree8a8bbf681f15209ae2ae6e528676249366356d79
parent66c782bb73c911a99dc7e41f8aa9659515e3a20b
Change the enumerate() example to bind the proxy by reference

Summary:
When compiling without optimizations binding the proxy by
reference is slightly faster (no differences in opt mode), so change
the documentation to recommend this syntax.

The proxy can still be bound by `auto`, `const auto`, and `const
auto&`, in all case behaving as expected and with no overhead in opt
mode. Added a test to make sure these all work.

Reviewed By: yfeldblum, luciang

Differential Revision: D6688958

fbshipit-source-id: 7c6b460a01708786bda7614546fa2e1667f27299
folly/container/Enumerate.h
folly/container/test/EnumerateTest.cpp
folly/container/test/ForeachBenchmark.cpp