Skip to content

Commit 28c9481

Browse files
authored
Implicitly create bytes
1 parent bf75bb3 commit 28c9481

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cppjson/src/object.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "cppjson/object.hpp"
22
#include <new>
33
#include <stdexcept>
4+
#include <cstdlib>
45

56
constexpr std::size_t DataStorageSize = std::max({sizeof(std::string), sizeof(cppjson::Object), sizeof(double), sizeof(bool)});
67

@@ -11,7 +12,7 @@ cppjson::JsonObject::JsonObject(const cppjson::JsonObject& other)
1112
if (other._dataStorage == nullptr) return;
1213

1314
this->_dataType = other._dataType;
14-
this->_dataStorage = ::operator new(DataStorageSize);
15+
this->_dataStorage = static_cast<std::byte*>(::operator new(DataStorageSize));
1516
std::memcpy(this->_dataStorage, other._dataStorage, DataStorageSize);
1617
}
1718
cppjson::JsonObject::JsonObject(JsonObject&& other)
@@ -24,7 +25,7 @@ cppjson::JsonObject& cppjson::JsonObject::operator=(const cppjson::JsonObject& o
2425
if (&other != this)
2526
{
2627
this->_dataType = other._dataType;
27-
this->_dataStorage = ::operator new(DataStorageSize);
28+
this->_dataStorage = static_cast<std::byte*>(::operator new(DataStorageSize));
2829
std::memcpy(this->_dataStorage, other._dataStorage, DataStorageSize);
2930
}
3031
return *this;

0 commit comments

Comments
 (0)