From 2199580590342381d07b215613be82964ab44871 Mon Sep 17 00:00:00 2001 From: tzik Date: Thu, 26 Apr 2018 17:38:28 +0900 Subject: [PATCH] Remove deprecated std::bind2nd and std::ptr_fun std::bind2nd and std::ptr_fun are deprecated in C++11 and removed in C++17. This CL removes their usage, so that the code base is ready for C++17. Bug: chromium:752720 Change-Id: I6ec0b596202ebf84cf7b8744f516a76ac8328ccd Reviewed-on: https://webrtc-review.googlesource.com/72360 Reviewed-by: Niels Moller Reviewed-by: Karl Wiberg Commit-Queue: Taiju Tsuiki Cr-Commit-Position: refs/heads/master@{#23083} --- pc/mediasession.cc | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/pc/mediasession.cc b/pc/mediasession.cc index eba3249d03..92a6106fc8 100644 --- a/pc/mediasession.cc +++ b/pc/mediasession.cc @@ -548,22 +548,6 @@ static bool GetCryptosByName(const SessionDescription* sdesc, return true; } -// Predicate function used by the remove_if. -// Returns true if the |crypto|'s cipher_suite is not found in |filter|. -static bool CryptoNotFound(const CryptoParams crypto, - const CryptoParamsVec* filter) { - if (filter == NULL) { - return true; - } - for (CryptoParamsVec::const_iterator it = filter->begin(); - it != filter->end(); ++it) { - if (it->cipher_suite == crypto.cipher_suite) { - return false; - } - } - return true; -} - // Prunes the |target_cryptos| by removing the crypto params (cipher_suite) // which are not available in |filter|. static void PruneCryptos(const CryptoParamsVec& filter, @@ -571,11 +555,19 @@ static void PruneCryptos(const CryptoParamsVec& filter, if (!target_cryptos) { return; } - target_cryptos->erase(std::remove_if(target_cryptos->begin(), - target_cryptos->end(), - bind2nd(ptr_fun(CryptoNotFound), - &filter)), - target_cryptos->end()); + + target_cryptos->erase( + std::remove_if(target_cryptos->begin(), target_cryptos->end(), + // Returns true if the |crypto|'s cipher_suite is not + // found in |filter|. + [&filter](const CryptoParams& crypto) { + for (const CryptoParams& entry : filter) { + if (entry.cipher_suite == crypto.cipher_suite) + return false; + } + return true; + }), + target_cryptos->end()); } bool IsRtpProtocol(const std::string& protocol) {