mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
[cpp23] Remove usage of std::aligned_storage in nearby
Deprecated in C++23. Details in https://crbug.com/388068052. PiperOrigin-RevId: 722745132
This commit is contained in:
@@ -43,9 +43,8 @@ ThroughputRecorder::ThroughputRecorder(int64_t payload_id)
|
||||
: payload_id_(payload_id) {}
|
||||
|
||||
ThroughputRecorderContainer& ThroughputRecorderContainer::GetInstance() {
|
||||
static std::aligned_storage_t<sizeof(ThroughputRecorderContainer),
|
||||
alignof(ThroughputRecorderContainer)>
|
||||
storage;
|
||||
alignas(ThroughputRecorderContainer) static char
|
||||
storage[sizeof(ThroughputRecorderContainer)];
|
||||
static ThroughputRecorderContainer* env =
|
||||
new (&storage) ThroughputRecorderContainer();
|
||||
return *env;
|
||||
|
||||
@@ -95,17 +95,10 @@ MultiplexSocket::MultiplexSocket(std::shared_ptr<MediumSocket> physical_socket)
|
||||
absl::flat_hash_map<std::pair<std::string, Medium>,
|
||||
MultiplexIncomingConnectionCb>&
|
||||
MultiplexSocket::GetIncomingConnectionCallbacks() {
|
||||
static std::aligned_storage_t<
|
||||
sizeof(absl::flat_hash_map<std::pair<std::string, Medium>,
|
||||
MultiplexIncomingConnectionCb>),
|
||||
alignof(absl::flat_hash_map<std::pair<std::string, Medium>,
|
||||
MultiplexIncomingConnectionCb>)>
|
||||
storage;
|
||||
static absl::flat_hash_map<std::pair<std::string, Medium>,
|
||||
MultiplexIncomingConnectionCb>*
|
||||
incoming_connection_callbacks =
|
||||
new (&storage) absl::flat_hash_map<std::pair<std::string, Medium>,
|
||||
MultiplexIncomingConnectionCb>();
|
||||
using MapType = absl::flat_hash_map<std::pair<std::string, Medium>,
|
||||
MultiplexIncomingConnectionCb>;
|
||||
alignas(MapType) static char storage[sizeof(MapType)];
|
||||
static MapType* incoming_connection_callbacks = new (&storage) MapType();
|
||||
|
||||
return *incoming_connection_callbacks;
|
||||
}
|
||||
@@ -121,23 +114,18 @@ MultiplexSocket* MultiplexSocket::CreateIncomingSocket(
|
||||
static MultiplexSocket* multiplex_incoming_socket = nullptr;
|
||||
switch (physical_socket->GetMedium()) {
|
||||
case Medium::BLUETOOTH:
|
||||
static std::aligned_storage_t<sizeof(MultiplexSocket),
|
||||
alignof(MultiplexSocket)>
|
||||
storage_bt;
|
||||
alignas(MultiplexSocket) static char storage_bt[sizeof(MultiplexSocket)];
|
||||
multiplex_incoming_socket =
|
||||
new (&storage_bt) MultiplexSocket(physical_socket);
|
||||
break;
|
||||
case Medium::BLE:
|
||||
static std::aligned_storage_t<sizeof(MultiplexSocket),
|
||||
alignof(MultiplexSocket)>
|
||||
storage_ble;
|
||||
alignas(MultiplexSocket) static char storage_ble[sizeof(MultiplexSocket)];
|
||||
multiplex_incoming_socket =
|
||||
new (&storage_ble) MultiplexSocket(physical_socket);
|
||||
break;
|
||||
case Medium::WIFI_LAN:
|
||||
static std::aligned_storage_t<sizeof(MultiplexSocket),
|
||||
alignof(MultiplexSocket)>
|
||||
storage_wlan;
|
||||
alignas(
|
||||
MultiplexSocket) static char storage_wlan[sizeof(MultiplexSocket)];
|
||||
multiplex_incoming_socket =
|
||||
new (&storage_wlan) MultiplexSocket(physical_socket);
|
||||
break;
|
||||
@@ -169,23 +157,18 @@ MultiplexSocket* MultiplexSocket::CreateOutgoingSocket(
|
||||
static MultiplexSocket* multiplex_outgoing_socket = nullptr;
|
||||
switch (physical_socket->GetMedium()) {
|
||||
case Medium::BLUETOOTH:
|
||||
static std::aligned_storage_t<sizeof(MultiplexSocket),
|
||||
alignof(MultiplexSocket)>
|
||||
storage_bt;
|
||||
alignas(MultiplexSocket) static char storage_bt[sizeof(MultiplexSocket)];
|
||||
multiplex_outgoing_socket =
|
||||
new (&storage_bt) MultiplexSocket(physical_socket);
|
||||
break;
|
||||
case Medium::BLE:
|
||||
static std::aligned_storage_t<sizeof(MultiplexSocket),
|
||||
alignof(MultiplexSocket)>
|
||||
storage_ble;
|
||||
alignas(MultiplexSocket) static char storage_ble[sizeof(MultiplexSocket)];
|
||||
multiplex_outgoing_socket =
|
||||
new (&storage_ble) MultiplexSocket(physical_socket);
|
||||
break;
|
||||
case Medium::WIFI_LAN:
|
||||
static std::aligned_storage_t<sizeof(MultiplexSocket),
|
||||
alignof(MultiplexSocket)>
|
||||
storage_wlan;
|
||||
alignas(
|
||||
MultiplexSocket) static char storage_wlan[sizeof(MultiplexSocket)];
|
||||
multiplex_outgoing_socket =
|
||||
new (&storage_wlan) MultiplexSocket(physical_socket);
|
||||
break;
|
||||
|
||||
@@ -137,7 +137,7 @@ MurocDefs::INTEL_CALLBACK g_intel_event_cb_handle = {IntelEventHandler,
|
||||
#endif
|
||||
|
||||
WifiIntel& WifiIntel::GetInstance() {
|
||||
static std::aligned_storage_t<sizeof(WifiIntel), alignof(WifiIntel)> storage;
|
||||
alignas(WifiIntel) static char storage[sizeof(WifiIntel)];
|
||||
static WifiIntel* instance = new (&storage) WifiIntel();
|
||||
return *instance;
|
||||
}
|
||||
|
||||
@@ -52,9 +52,7 @@
|
||||
namespace nearby {
|
||||
|
||||
MediumEnvironment& MediumEnvironment::Instance() {
|
||||
static std::aligned_storage_t<sizeof(MediumEnvironment),
|
||||
alignof(MediumEnvironment)>
|
||||
storage;
|
||||
alignas(MediumEnvironment) static char storage[sizeof(MediumEnvironment)];
|
||||
static MediumEnvironment* env = new (&storage) MediumEnvironment();
|
||||
return *env;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user