Skip to content

Commit

Permalink
Change lambda arg to auto in access control server
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mlepage-google committed Dec 6, 2021
1 parent 53926dd commit 12b0651
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/app/AttributeAccessInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AttributeReportBuilder
* EncodeValue encodes the value field of the report, it should be called exactly once.
*/
template <typename... Ts>
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<Ts>(aArgs)...);
Expand All @@ -98,7 +98,7 @@ class AttributeValueEncoder
ListEncodeHelper(AttributeValueEncoder & encoder) : mAttributeValueEncoder(encoder) {}

template <typename... Ts>
CHIP_ERROR Encode(Ts... aArgs) const
CHIP_ERROR Encode(Ts &&... aArgs) const
{
return mAttributeValueEncoder.EncodeListItem(std::forward<Ts>(aArgs)...);
}
Expand Down Expand Up @@ -152,7 +152,7 @@ class AttributeValueEncoder
* operation.
*/
template <typename... Ts>
CHIP_ERROR Encode(Ts... aArgs)
CHIP_ERROR Encode(Ts &&... aArgs)
{
mTriedEncode = true;
return EncodeAttributeReportIB(std::forward<Ts>(aArgs)...);
Expand Down Expand Up @@ -209,7 +209,7 @@ class AttributeValueEncoder
friend class ListEncodeHelper;

template <typename... Ts>
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.
Expand Down Expand Up @@ -242,7 +242,7 @@ class AttributeValueEncoder
* Actual logic for encoding a single AttributeReportIB in AttributeReportIBs.
*/
template <typename... Ts>
CHIP_ERROR EncodeAttributeReportIB(Ts... aArgs)
CHIP_ERROR EncodeAttributeReportIB(Ts &&... aArgs)
{
mTriedEncode = true;
AttributeReportBuilder builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 12b0651

Please sign in to comment.