From 4626e0dbbee6ebd07bf035e4ed9b85ac959abbb3 Mon Sep 17 00:00:00 2001 From: Alex Rucker Date: Tue, 16 Jan 2024 23:35:37 +0000 Subject: [PATCH] Respond to MR comments Move the new is_pod method to simdb::utils::is_pod, so that it won't be confused with std::is_pod in the event of `using namespace std'. Also move the struct definition to a new file, `simdb/utils/CompatUtils.hpp', so that it is centralized in one place. --- .../simdb/schema/ColumnMetaStructs.hpp | 37 ++++++++----------- .../simdb/include/simdb/utils/CompatUtils.hpp | 19 ++++++++++ sparta/simdb/src/ObjectRef.cpp | 4 +- sparta/sparta/pairs/SpartaKeyPairs.hpp | 5 ++- 4 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 sparta/simdb/include/simdb/utils/CompatUtils.hpp diff --git a/sparta/simdb/include/simdb/schema/ColumnMetaStructs.hpp b/sparta/simdb/include/simdb/schema/ColumnMetaStructs.hpp index 5c7ac5f404..72509bcfab 100644 --- a/sparta/simdb/include/simdb/schema/ColumnMetaStructs.hpp +++ b/sparta/simdb/include/simdb/schema/ColumnMetaStructs.hpp @@ -11,6 +11,7 @@ #include "simdb/schema/ColumnTypedefs.hpp" #include "simdb/schema/DatabaseTypedefs.hpp" #include "simdb/Errors.hpp" +#include "simdb/utils/CompatUtils.hpp" #include #include @@ -23,12 +24,6 @@ namespace simdb { template struct column_info; -template -struct is_pod { - static constexpr bool value = std::is_trivial::value - && std::is_standard_layout::value; -}; - //! int8_t template <> struct column_info { @@ -36,7 +31,7 @@ struct column_info { return ColumnDataType::int8_t; } using value_type = int8_t; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! uint8_t @@ -46,7 +41,7 @@ struct column_info { return ColumnDataType::uint8_t; } using value_type = uint8_t; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! int16_t @@ -56,7 +51,7 @@ struct column_info { return ColumnDataType::int16_t; } using value_type = int16_t; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! uint16_t @@ -66,7 +61,7 @@ struct column_info { return ColumnDataType::uint16_t; } using value_type = uint16_t; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! int32_t @@ -76,7 +71,7 @@ struct column_info { return ColumnDataType::int32_t; } using value_type = int32_t; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! uint32_t @@ -86,7 +81,7 @@ struct column_info { return ColumnDataType::uint32_t; } using value_type = uint32_t; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! int64_t @@ -96,7 +91,7 @@ struct column_info { return ColumnDataType::int64_t; } using value_type = int64_t; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! uint64_t @@ -106,7 +101,7 @@ struct column_info { return ColumnDataType::uint64_t; } using value_type = uint64_t; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! float @@ -116,7 +111,7 @@ struct column_info { return ColumnDataType::float_t; } using value_type = float; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! double @@ -126,7 +121,7 @@ struct column_info { return ColumnDataType::double_t; } using value_type = double; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! string @@ -139,7 +134,7 @@ struct column_info::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! char @@ -149,7 +144,7 @@ struct column_info { return ColumnDataType::char_t; } using value_type = char; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! Vectors of raw bytes are stored as blobs (void* / opaque) @@ -161,7 +156,7 @@ struct column_info::value_type; - static constexpr bool is_fixed_size = is_pod::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! Blob descriptor @@ -173,11 +168,11 @@ struct column_info::value; + static constexpr bool is_fixed_size = utils::is_pod::value; }; //! See if the given column data type has a fixed number -//! of bytes, as determined by is_pod +//! of bytes, as determined by utils::is_pod inline bool getColumnIsFixedSize(const ColumnDataType dtype) { using dt = ColumnDataType; diff --git a/sparta/simdb/include/simdb/utils/CompatUtils.hpp b/sparta/simdb/include/simdb/utils/CompatUtils.hpp new file mode 100644 index 0000000000..ec7bfc721b --- /dev/null +++ b/sparta/simdb/include/simdb/utils/CompatUtils.hpp @@ -0,0 +1,19 @@ +// -*- C++ -*- + +#pragma once + +#include + +namespace simdb { +namespace utils { + +//! \brief Replacement for std::is_pod, which was deprecated in C++20 + +template +struct is_pod { + static constexpr bool value = std::is_trivial::value + && std::is_standard_layout::value; +}; + +} // namespace utils +} // namespace simdb diff --git a/sparta/simdb/src/ObjectRef.cpp b/sparta/simdb/src/ObjectRef.cpp index f63bde7636..0cd16cea21 100644 --- a/sparta/simdb/src/ObjectRef.cpp +++ b/sparta/simdb/src/ObjectRef.cpp @@ -4,6 +4,7 @@ #include "simdb/utils/ObjectQuery.hpp" #include "simdb/TableRef.hpp" #include "simdb/DbConnProxy.hpp" +#include "simdb/utils/CompatUtils.hpp" //SQLite-specific headers #include "simdb/impl/sqlite/TransactionUtils.hpp" @@ -96,8 +97,7 @@ PropertyDataT LOCAL_getScalarProperty(const std::string & table_name, //! without using ObjectQuery. template typename std::enable_if< - std::is_trivial::value && - std::is_standard_layout::value, + utils::is_pod::value, PropertyDataT>::type LOCAL_getScalarPropertyNoObjectQuery( const std::string & table_name, diff --git a/sparta/sparta/pairs/SpartaKeyPairs.hpp b/sparta/sparta/pairs/SpartaKeyPairs.hpp index 421dd074cc..c212f22e88 100644 --- a/sparta/sparta/pairs/SpartaKeyPairs.hpp +++ b/sparta/sparta/pairs/SpartaKeyPairs.hpp @@ -30,6 +30,8 @@ #include "sparta/utils/MetaTypeList.hpp" #include "sparta/utils/MetaStructs.hpp" #include "sparta/utils/DetectMemberUtils.hpp" +#include "simdb/utils/CompatUtils.hpp" + namespace sparta { @@ -1691,8 +1693,7 @@ namespace sparta { template MetaStruct::enable_if_t< std::is_integral>::value && - std::is_trivial>::value && - std::is_standard_layout>::value && + simdb::utils::is_pod>::value && !MetaStruct::is_bool>::value, void> updateValueInCache_(