Integrated std::byte added to C++17 recently
This commit is contained in:
TheDoctor
2019-10-15 21:03:24 +01:00
parent 8fbda17074
commit 5ab59a6fb8
49 changed files with 424 additions and 427 deletions

View File

@ -4,8 +4,7 @@
// now ive hit a wall
// casting vs bitshifting
#include <cstdint>
#include <cstring>
#include "VoidNet_LL/Net.hpp"
namespace std
{
@ -13,15 +12,15 @@ namespace std
{
public:
template<typename T>
inline static uint8_t *ToBytes(T value)
inline static byte *ToBytes(T value)
{
uint8_t *data = new uint8_t[sizeof(T)]();
byte *data = new byte[sizeof(T)]();
memcpy(data, &value, sizeof(T));
return data;
}
template<typename T>
inline static T FromBytes(uint8_t *data)
inline static T FromBytes(byte *data)
{
if (!data)
throw std::invalid_argument("cant have null parameter -> ByteConverter::FromBytes");