Downgrade for old compiler
This commit is contained in:
@ -3,6 +3,7 @@ set(headers
|
|||||||
src/espcrc32builder.h
|
src/espcrc32builder.h
|
||||||
src/esprandom.h
|
src/esprandom.h
|
||||||
src/espstrutils.h
|
src/espstrutils.h
|
||||||
|
src/futurecpp.h
|
||||||
src/lockhelper.h
|
src/lockhelper.h
|
||||||
src/lockingqueue.h
|
src/lockingqueue.h
|
||||||
src/recursivelockhelper.h
|
src/recursivelockhelper.h
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
|
|
||||||
// 3rdparty lib includes
|
// 3rdparty lib includes
|
||||||
|
#include <futurecpp.h>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
|
30
src/futurecpp.h
Normal file
30
src/futurecpp.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// system includes
|
||||||
|
#include <cstring>
|
||||||
|
#include <limits>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
// C++20 backports (until espressif finally updates their aged compiler suite)
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
template <class To, class From>
|
||||||
|
typename std::enable_if_t<
|
||||||
|
sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From> && std::is_trivially_copyable_v<To>,
|
||||||
|
To>
|
||||||
|
// constexpr support needs compiler magic
|
||||||
|
bit_cast(const From& src) noexcept
|
||||||
|
{
|
||||||
|
static_assert(std::is_trivially_constructible_v<To>,
|
||||||
|
"This implementation additionally requires destination type to be trivially constructible");
|
||||||
|
|
||||||
|
To dst;
|
||||||
|
std::memcpy(&dst, &src, sizeof(To));
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename EnumT, typename = std::enable_if_t<std::is_enum<EnumT>{}>>
|
||||||
|
constexpr std::underlying_type_t<EnumT> to_underlying(EnumT e) noexcept {
|
||||||
|
return static_cast<std::underlying_type_t<EnumT>>(e);
|
||||||
|
}
|
||||||
|
} // namespace std
|
@ -9,6 +9,9 @@
|
|||||||
// esp-idf includes
|
// esp-idf includes
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
|
|
||||||
|
// 3rdparty lib includes
|
||||||
|
#include <futurecpp.h>
|
||||||
|
|
||||||
namespace espcpputils {
|
namespace espcpputils {
|
||||||
namespace {
|
namespace {
|
||||||
constexpr const char * const TAG = "ESPCPPUTILS";
|
constexpr const char * const TAG = "ESPCPPUTILS";
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
// 3rdparty lib includes
|
// 3rdparty lib includes
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
#include <futurecpp.h>
|
||||||
|
|
||||||
namespace espcpputils {
|
namespace espcpputils {
|
||||||
class websocket_client
|
class websocket_client
|
||||||
|
Reference in New Issue
Block a user