1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00

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

View File

@@ -88,10 +88,15 @@ template<typename T> T clamp(T val, T min, T max);
*/
float lerp(float completion, float start, float end);
/// std::make_unique
// Not all platforms we support target C++14 yet, so we can't unconditionally use std::make_unique. Provide our own
// implementation if needed, and otherwise pull std::make_unique into scope so that we have a uniform API.
#if __cplusplus >= 201402L
using std::make_unique;
#else
template<typename T, typename... Args> std::unique_ptr<T> make_unique(Args &&...args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
#endif
/// Return a random 32 bit unsigned integer.
uint32_t random_uint32();