From 12b065153dc24be37980887f1762e2b090aab791 Mon Sep 17 00:00:00 2001 From: Marc Lepage Date: Mon, 6 Dec 2021 17:05:37 -0500 Subject: [PATCH] Change lambda arg to auto in access control server It was TagBoundEncoder, but now it's ListEncodeHelper. Also had to fix the perfect forwarding in AttributeValueEncoder and ListEncodeHelper and other template functions in the file, so it doesn't try to copy its args. --- src/app/AttributeAccessInterface.h | 10 +++++----- .../access-control-server/access-control-server.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/AttributeAccessInterface.h b/src/app/AttributeAccessInterface.h index 796f7b6de46696..f58331c8d1714a 100644 --- a/src/app/AttributeAccessInterface.h +++ b/src/app/AttributeAccessInterface.h @@ -74,7 +74,7 @@ class AttributeReportBuilder * EncodeValue encodes the value field of the report, it should be called exactly once. */ template - CHIP_ERROR EncodeValue(AttributeReportIBs::Builder & aAttributeReportIBs, Ts... aArgs) + CHIP_ERROR EncodeValue(AttributeReportIBs::Builder & aAttributeReportIBs, Ts &&... aArgs) { return DataModel::Encode(*(aAttributeReportIBs.GetAttributeReport().GetAttributeData().GetWriter()), TLV::ContextTag(to_underlying(AttributeDataIB::Tag::kData)), std::forward(aArgs)...); @@ -98,7 +98,7 @@ class AttributeValueEncoder ListEncodeHelper(AttributeValueEncoder & encoder) : mAttributeValueEncoder(encoder) {} template - CHIP_ERROR Encode(Ts... aArgs) const + CHIP_ERROR Encode(Ts &&... aArgs) const { return mAttributeValueEncoder.EncodeListItem(std::forward(aArgs)...); } @@ -152,7 +152,7 @@ class AttributeValueEncoder * operation. */ template - CHIP_ERROR Encode(Ts... aArgs) + CHIP_ERROR Encode(Ts &&... aArgs) { mTriedEncode = true; return EncodeAttributeReportIB(std::forward(aArgs)...); @@ -209,7 +209,7 @@ class AttributeValueEncoder friend class ListEncodeHelper; template - CHIP_ERROR EncodeListItem(Ts... aArgs) + CHIP_ERROR EncodeListItem(Ts &&... aArgs) { // EncodeListItem must be called after EncodeEmptyList(), thus mCurrentEncodingListIndex and // mEncodeState.mCurrentEncodingListIndex are not invalid values. @@ -242,7 +242,7 @@ class AttributeValueEncoder * Actual logic for encoding a single AttributeReportIB in AttributeReportIBs. */ template - CHIP_ERROR EncodeAttributeReportIB(Ts... aArgs) + CHIP_ERROR EncodeAttributeReportIB(Ts &&... aArgs) { mTriedEncode = true; AttributeReportBuilder builder; diff --git a/src/app/clusters/access-control-server/access-control-server.cpp b/src/app/clusters/access-control-server/access-control-server.cpp index 302cb3ac060ede..c83969485d9dc2 100644 --- a/src/app/clusters/access-control-server/access-control-server.cpp +++ b/src/app/clusters/access-control-server/access-control-server.cpp @@ -350,7 +350,7 @@ CHIP_ERROR AccessControlAttribute::ReadAcl(AttributeValueEncoder & aEncoder) GetAccessControl().Entries(iterator); - CHIP_ERROR err = aEncoder.EncodeList([&](const TagBoundEncoder & encoder) -> CHIP_ERROR { + CHIP_ERROR err = aEncoder.EncodeList([&](const auto & encoder) -> CHIP_ERROR { while (iterator.Next(codec.entry) == CHIP_NO_ERROR) { encoder.Encode(codec);