diff --git a/CMakeLists.txt b/CMakeLists.txt index c7960f6..f52bb8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,6 +237,10 @@ install(EXPORT AthenaTargets DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT athena) if(NOT GEKKO) add_subdirectory(atdna) +# Test target +atdna(atdna_test.cpp atdna/test.hpp) +add_executable(atdna-test atdna/test.cpp atdna_test.cpp atdna/test.hpp) +target_link_libraries(atdna-test athena-core athena-libyaml) endif() ######### diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index fc92fa7..217c7f2 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -234,9 +234,4 @@ macro(atdna out) endif() endmacro() -# Test target -atdna(atdna_test.cpp test.hpp) -add_executable(atdna-test test.cpp atdna_test.cpp test.hpp) -target_link_libraries(atdna-test athena-core athena-libyaml) - endif() diff --git a/include/athena/DNAOp.hpp b/include/athena/DNAOp.hpp index f10e4ea..e3661c4 100644 --- a/include/athena/DNAOp.hpp +++ b/include/athena/DNAOp.hpp @@ -6,6 +6,7 @@ #include "YAMLDocReader.hpp" #include "YAMLDocWriter.hpp" #include "ChecksumsLiterals.hpp" +#include namespace athena::io { @@ -65,16 +66,15 @@ enum class PropType }; template -static inline constexpr bool __IsPODType() -{ - return std::is_arithmetic_v || - std::is_convertible_v || - std::is_convertible_v || - std::is_convertible_v || - std::is_convertible_v || - std::is_convertible_v || - std::is_convertible_v; -} +using __IsPODType = typename std::disjunction, + std::is_convertible, + std::is_convertible, + std::is_convertible, + std::is_convertible, + std::is_convertible, + std::is_convertible>; +template +inline constexpr bool __IsPODType_v = __IsPODType::value; template using __CastPODType = typename std::conditional_t, atVec2f, @@ -139,7 +139,7 @@ struct BinarySize BinarySize::Do(id, *reinterpret_cast(&var), s); } template - static typename std::enable_if_t<__IsPODType()> + static typename std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& s) { if (PropOp != PropType::None) @@ -151,7 +151,7 @@ struct BinarySize BinarySize::Do(id, static_cast(var), s); } template - static typename std::enable_if_t<__IsDNARecord() && PropOp != PropType::None> + static typename std::enable_if_t<__IsDNARecord_v && PropOp != PropType::None> Do(const PropId& id, T& var, StreamT& s) { /* Accessed via Enumerate, header */ @@ -159,7 +159,7 @@ struct BinarySize var.template Enumerate>(s); } template - static typename std::enable_if_t<__IsDNARecord() && PropOp == PropType::None> + static typename std::enable_if_t<__IsDNARecord_v && PropOp == PropType::None> Do(const PropId& id, T& var, StreamT& s) { var.template Enumerate>(s); @@ -347,7 +347,7 @@ struct Read Read::Do(id, *reinterpret_cast(&var), r); } template - static typename std::enable_if_t<__IsPODType()> + static typename std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& r) { using CastT = __CastPODType; @@ -398,7 +398,7 @@ struct Read { vector.clear(); vector.reserve(count); - for (size_t i = 0; i < count; ++i) + for (size_t i = 0; i < static_cast(count); ++i) { vector.emplace_back(); Read::Do(id, vector.back(), r); @@ -518,7 +518,7 @@ struct Write Write::Do(id, *reinterpret_cast(&var), w); } template - static typename std::enable_if_t<__IsPODType()> + static typename std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& w) { using CastT = __CastPODType; @@ -679,14 +679,14 @@ struct ReadYaml ReadYaml::Do(id, *reinterpret_cast(&var), r); } template - static typename std::enable_if_t<__IsPODType()> + static typename std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& r) { using CastT = __CastPODType; ReadYaml::Do(id, static_cast(var), r); } template - static typename std::enable_if_t<__IsDNARecord()> + static typename std::enable_if_t<__IsDNARecord_v> Do(const PropId& id, T& var, StreamT& r) { if (auto rec = r.enterSubRecord(id.name)) @@ -818,14 +818,14 @@ struct WriteYaml WriteYaml::Do(id, *reinterpret_cast(&var), w); } template - static typename std::enable_if_t<__IsPODType()> + static typename std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& w) { using CastT = __CastPODType; WriteYaml::Do(id, static_cast(var), w); } template - static typename std::enable_if_t<__IsDNARecord()> + static typename std::enable_if_t<__IsDNARecord_v> Do(const PropId& id, T& var, StreamT& w) { if (auto rec = w.enterSubRecord(id.name)) diff --git a/include/athena/DNAYaml.hpp b/include/athena/DNAYaml.hpp index a511cd7..d45afba 100644 --- a/include/athena/DNAYaml.hpp +++ b/include/athena/DNAYaml.hpp @@ -12,14 +12,14 @@ namespace athena::io template static inline const char* __GetDNAName(const T& dna, - typename std::enable_if_t()>* = 0) + typename std::enable_if_t>* = 0) { return dna.DNATypeV(); } template static inline const char* __GetDNAName(const T& dna, - typename std::enable_if_t()>* = 0) + typename std::enable_if_t>* = 0) { return dna.DNAType(); } diff --git a/include/athena/Global.hpp b/include/athena/Global.hpp index 4f3ae1a..14da238 100644 --- a/include/athena/Global.hpp +++ b/include/athena/Global.hpp @@ -146,17 +146,16 @@ template struct DNAV; template -static inline constexpr bool __IsDNARecord() -{ - return std::is_base_of_v, T> || - std::is_base_of_v, T>; -} +using __IsDNARecord = typename std::disjunction, T>, + std::is_base_of, T>>; template -static inline constexpr bool __IsDNAVRecord() -{ - return std::is_base_of_v, T> || - std::is_base_of_v, T>; -} +inline constexpr bool __IsDNARecord_v = __IsDNARecord::value; + +template +using __IsDNAVRecord = typename std::disjunction, T>, + std::is_base_of, T>>; +template +inline constexpr bool __IsDNAVRecord_v = __IsDNAVRecord::value; } } // Athena diff --git a/include/athena/YAMLCommon.hpp b/include/athena/YAMLCommon.hpp index 96b79ae..2170688 100644 --- a/include/athena/YAMLCommon.hpp +++ b/include/athena/YAMLCommon.hpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include "Global.hpp" namespace athena::io diff --git a/include/athena/YAMLDocReader.hpp b/include/athena/YAMLDocReader.hpp index e6dc994..0bbd214 100644 --- a/include/athena/YAMLDocReader.hpp +++ b/include/athena/YAMLDocReader.hpp @@ -49,7 +49,7 @@ public: template void enumerate(const char* name, T& record, - typename std::enable_if_t<__IsDNARecord()>* = 0) + typename std::enable_if_t<__IsDNARecord_v>* = 0) { if (auto rec = enterSubRecord(name)) record.read(*this); diff --git a/include/athena/YAMLDocWriter.hpp b/include/athena/YAMLDocWriter.hpp index 8e15199..6915619 100644 --- a/include/athena/YAMLDocWriter.hpp +++ b/include/athena/YAMLDocWriter.hpp @@ -40,7 +40,7 @@ public: template void enumerate(const char* name, T& record, - typename std::enable_if_t<__IsDNARecord()>* = 0) + typename std::enable_if_t<__IsDNARecord_v>* = 0) { if (auto rec = enterSubRecord(name)) record.write(*this);