Skip to content

Commit

Permalink
made endian checks constexpr (#6)
Browse files Browse the repository at this point in the history
* added constexpr endian checks

* updated gen script
Husenap authored Jun 11, 2021
1 parent 4f83673 commit 4843dd2
Showing 6 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dubu_serialize/src/dubu_serialize/serializer/Serializer.h
Original file line number Diff line number Diff line change
@@ -35,12 +35,12 @@ template <typename T>
struct Serializer<T, true> {
void Read(ReadBuffer& buffer, T& object) {
buffer.Read(reinterpret_cast<char*>(&object), sizeof(T));
if (Endian::big) {
if constexpr (Endian::big) {
FlipEndian(object);
}
}
void Write(WriteBuffer& buffer, const T& object) {
if (Endian::big) {
if constexpr (Endian::big) {
T objectCopy(object);
FlipEndian(objectCopy);
buffer.Write(reinterpret_cast<const char*>(&objectCopy), sizeof(T));
2 changes: 2 additions & 0 deletions scripts/build.bat → scripts/build
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#! /bin/bash

cmake --build .build/
3 changes: 3 additions & 0 deletions scripts/gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

cmake . -B.build -Ax64
1 change: 0 additions & 1 deletion scripts/gen.bat

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/open.bat → scripts/open
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#! /bin/bash

cmake --open .build/
2 changes: 1 addition & 1 deletion scripts/test.bat → scripts/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@echo off
#! /bin/bash

cmake . -B.build -Ax64
cmake --build .build/

0 comments on commit 4843dd2

Please sign in to comment.