Skip to content

Commit

Permalink
StdCompiler: Add Value overload for standard libraries where std::int…
Browse files Browse the repository at this point in the history
…64_t != long long

Certain standard libraries, e.g. a self-built libc++ or clang under Termux,
define std::int64_t as long. However, std::chrono::duration uses long long for
many durations, causing an error.
  • Loading branch information
Fulgen301 committed Aug 8, 2023
1 parent 123d311 commit 82dea65
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/StdCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ class StdCompiler
void Value(bool &rBool) { Boolean(rBool); }
void Value(std::string &rString, StdCompiler::RawCompileType eRawType = StdCompiler::RCT_Escaped) { String(rString, eRawType); }

template<typename T> requires (!std::same_as<long long, std::int64_t> && std::same_as<std::make_signed_t<T>, long long>)
void Value(T &rInt)
{
std::conditional_t<std::is_signed_v<T>, std::int64_t, std::uint64_t> value{rInt};
Value(value);
rInt = value;
}

// Compiling/Decompiling (may throw a data format exception!)
template <class T> inline void Compile(T &&rStruct)
{
Expand Down

0 comments on commit 82dea65

Please sign in to comment.