mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 02:28:28 +02:00
Use standard version of make_unique when available (#2292)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user