Use standard version of make_unique when available (#2292)

This commit is contained in:
Oxan van Leeuwen
2021-09-14 14:27:35 +02:00
committed by GitHub
parent 4cc2817fcd
commit 716039e452
8 changed files with 35 additions and 20 deletions
+6 -4
View File
@@ -1,4 +1,6 @@
#include "pn532.h"
#include <memory>
#include "esphome/core/log.h"
// Based on:
@@ -104,7 +106,7 @@ void PN532::loop() {
if (!success) {
// Something failed
if (!this->current_uid_.empty()) {
auto tag = std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(this->current_uid_)};
auto tag = make_unique<nfc::NfcTag>(this->current_uid_);
for (auto *trigger : this->triggers_ontagremoved_)
trigger->process(tag);
}
@@ -117,7 +119,7 @@ void PN532::loop() {
if (num_targets != 1) {
// no tags found or too many
if (!this->current_uid_.empty()) {
auto tag = std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(this->current_uid_)};
auto tag = make_unique<nfc::NfcTag>(this->current_uid_);
for (auto *trigger : this->triggers_ontagremoved_)
trigger->process(tag);
}
@@ -281,9 +283,9 @@ std::unique_ptr<nfc::NfcTag> PN532::read_tag_(std::vector<uint8_t> &uid) {
return this->read_mifare_ultralight_tag_(uid);
} else if (type == nfc::TAG_TYPE_UNKNOWN) {
ESP_LOGV(TAG, "Cannot determine tag type");
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid)};
return make_unique<nfc::NfcTag>(uid);
} else {
return std::unique_ptr<nfc::NfcTag>{new nfc::NfcTag(uid)};
return make_unique<nfc::NfcTag>(uid);
}
}