From c40ee0531acc3d2316d60c6df6cb195305ac0473 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 18 Aug 2018 12:13:36 -1000 Subject: [PATCH] Allow DNAOp to transparently handle cv-qualified types --- include/athena/DNAOp.hpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/include/athena/DNAOp.hpp b/include/athena/DNAOp.hpp index 52f2a08..02bffcd 100644 --- a/include/athena/DNAOp.hpp +++ b/include/athena/DNAOp.hpp @@ -66,24 +66,24 @@ enum class PropType }; template -using __IsPODType = typename std::disjunction, - std::is_convertible, - std::is_convertible, - std::is_convertible, - std::is_convertible, - std::is_convertible, - std::is_convertible>; +using __IsPODType = typename std::disjunction>, + std::is_convertible&, atVec2f&>, + std::is_convertible&, atVec3f&>, + std::is_convertible&, atVec4f&>, + std::is_convertible&, atVec2d&>, + std::is_convertible&, atVec3d&>, + std::is_convertible&, atVec4d&>>; template inline constexpr bool __IsPODType_v = __IsPODType::value; template -using __CastPODType = typename std::conditional_t, atVec2f, - std::conditional_t, atVec3f, - std::conditional_t, atVec4f, - std::conditional_t, atVec2d, - std::conditional_t, atVec3d, - std::conditional_t, atVec4d, - T>>>>>>; +using __CastPODType = typename std::conditional_t&, atVec2f&>, atVec2f, + std::conditional_t&, atVec3f&>, atVec3f, + std::conditional_t&, atVec4f&>, atVec4f, + std::conditional_t&, atVec2d&>, atVec2d, + std::conditional_t&, atVec3d&>, atVec3d, + std::conditional_t&, atVec4d&>, atVec4d, + std::remove_cv_t>>>>>>; template static inline uint16_t __Read16(IStreamReader& r) @@ -148,7 +148,7 @@ struct BinarySize s += 6; } using CastT = __CastPODType; - BinarySize::Do(id, static_cast(var), s); + BinarySize::Do(id, static_cast(const_cast&>(var)), s); } template static typename std::enable_if_t<__IsDNARecord_v && PropOp != PropType::None> @@ -530,10 +530,10 @@ struct Write else __Write32(w, id.rcrc32); size_t binarySize = 0; - BinarySize::Do(id, static_cast(var), binarySize); + BinarySize::Do(id, static_cast(const_cast&>(var)), binarySize); __Write16(w, atUint16(binarySize)); } - Write::Do(id, static_cast(var), w); + Write::Do(id, static_cast(const_cast&>(var)), w); } template static typename std::enable_if_t<__IsDNARecord() && PropOp != PropType::None> @@ -822,7 +822,7 @@ struct WriteYaml Do(const PropId& id, T& var, StreamT& w) { using CastT = __CastPODType; - WriteYaml::Do(id, static_cast(var), w); + WriteYaml::Do(id, static_cast(const_cast&>(var)), w); } template static typename std::enable_if_t<__IsDNARecord_v>