Add style guide rules for std::bind and std::function

We keep std::bind forbidden just like before, but suggest another
alternative than the Chromium style guide does.

We allow std::function, overriding the Chromium style guide which
forbids it on grounds not really applicable to WebRTC.

Bug: none
Change-Id: Iad07485652064a67020a494466d2b212bad568c0
Notry: true
Reviewed-on: https://webrtc-review.googlesource.com/63028
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22553}
This commit is contained in:
Karl Wiberg 2018-03-19 23:27:35 +01:00 committed by Commit Bot
parent 92120972ea
commit 0d44625b8f

View File

@ -109,6 +109,18 @@ implements the signal. It may:
sigslot::signal<int>& SignalFoo() { return bar_.SignalFoo(); }
```
### std::bind
Dont use `std::bind`—there are pitfalls, and lambdas are almost as
succinct and already familiar to modern C++ programmers.
### std::function
`std::function` is allowed, but remember that its not the right tool
for every occasion. Prefer to use interfaces when that makes sense,
and consider `rtc::FunctionView` for cases where the callee will not
save the function object.
## **C**
Theres a substantial chunk of legacy C code in WebRTC, and a lot of