Skip to content

Commit

Permalink
Changes for Sparta @ C++23
Browse files Browse the repository at this point in the history
Two changes need to be accounted for:

1. C++20's DR 2237, which forbids writing constructors as templates.
2. std::is_pod<T> is deprecated, and needs to be replaced using std::is_trival<T> && std::is_standard_layout<T>
  • Loading branch information
acrucker authored and klingaard committed Jan 17, 2024
1 parent 8b16b21 commit 8291100
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
36 changes: 21 additions & 15 deletions sparta/simdb/include/simdb/schema/ColumnMetaStructs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ namespace simdb {
template <typename ColumnT, typename Enable = void>
struct column_info;

template<typename T>
struct is_pod {
static constexpr bool value = std::is_trivial<T>::value
&& std::is_standard_layout<T>::value;
};

//! int8_t
template <>
struct column_info<int8_t> {
static ColumnDataType data_type() {
return ColumnDataType::int8_t;
}
using value_type = int8_t;
static constexpr bool is_fixed_size = std::is_pod<int8_t>::value;
static constexpr bool is_fixed_size = is_pod<int8_t>::value;
};

//! uint8_t
Expand All @@ -40,7 +46,7 @@ struct column_info<uint8_t> {
return ColumnDataType::uint8_t;
}
using value_type = uint8_t;
static constexpr bool is_fixed_size = std::is_pod<uint8_t>::value;
static constexpr bool is_fixed_size = is_pod<uint8_t>::value;
};

//! int16_t
Expand All @@ -50,7 +56,7 @@ struct column_info<int16_t> {
return ColumnDataType::int16_t;
}
using value_type = int16_t;
static constexpr bool is_fixed_size = std::is_pod<int16_t>::value;
static constexpr bool is_fixed_size = is_pod<int16_t>::value;
};

//! uint16_t
Expand All @@ -60,7 +66,7 @@ struct column_info<uint16_t> {
return ColumnDataType::uint16_t;
}
using value_type = uint16_t;
static constexpr bool is_fixed_size = std::is_pod<uint16_t>::value;
static constexpr bool is_fixed_size = is_pod<uint16_t>::value;
};

//! int32_t
Expand All @@ -70,7 +76,7 @@ struct column_info<int32_t> {
return ColumnDataType::int32_t;
}
using value_type = int32_t;
static constexpr bool is_fixed_size = std::is_pod<int32_t>::value;
static constexpr bool is_fixed_size = is_pod<int32_t>::value;
};

//! uint32_t
Expand All @@ -80,7 +86,7 @@ struct column_info<uint32_t> {
return ColumnDataType::uint32_t;
}
using value_type = uint32_t;
static constexpr bool is_fixed_size = std::is_pod<uint32_t>::value;
static constexpr bool is_fixed_size = is_pod<uint32_t>::value;
};

//! int64_t
Expand All @@ -90,7 +96,7 @@ struct column_info<int64_t> {
return ColumnDataType::int64_t;
}
using value_type = int64_t;
static constexpr bool is_fixed_size = std::is_pod<int64_t>::value;
static constexpr bool is_fixed_size = is_pod<int64_t>::value;
};

//! uint64_t
Expand All @@ -100,7 +106,7 @@ struct column_info<uint64_t> {
return ColumnDataType::uint64_t;
}
using value_type = uint64_t;
static constexpr bool is_fixed_size = std::is_pod<uint64_t>::value;
static constexpr bool is_fixed_size = is_pod<uint64_t>::value;
};

//! float
Expand All @@ -110,7 +116,7 @@ struct column_info<float> {
return ColumnDataType::float_t;
}
using value_type = float;
static constexpr bool is_fixed_size = std::is_pod<float>::value;
static constexpr bool is_fixed_size = is_pod<float>::value;
};

//! double
Expand All @@ -120,7 +126,7 @@ struct column_info<double> {
return ColumnDataType::double_t;
}
using value_type = double;
static constexpr bool is_fixed_size = std::is_pod<double>::value;
static constexpr bool is_fixed_size = is_pod<double>::value;
};

//! string
Expand All @@ -133,7 +139,7 @@ struct column_info<ColumnT, typename std::enable_if<
return ColumnDataType::string_t;
}
using value_type = ColumnT;
static constexpr bool is_fixed_size = std::is_pod<std::string>::value;
static constexpr bool is_fixed_size = is_pod<std::string>::value;
};

//! char
Expand All @@ -143,7 +149,7 @@ struct column_info<char> {
return ColumnDataType::char_t;
}
using value_type = char;
static constexpr bool is_fixed_size = std::is_pod<char>::value;
static constexpr bool is_fixed_size = is_pod<char>::value;
};

//! Vectors of raw bytes are stored as blobs (void* / opaque)
Expand All @@ -155,7 +161,7 @@ struct column_info<ColumnT, typename std::enable_if<
return ColumnDataType::blob_t;
}
using value_type = typename is_container<ColumnT>::value_type;
static constexpr bool is_fixed_size = std::is_pod<ColumnT>::value;
static constexpr bool is_fixed_size = is_pod<ColumnT>::value;
};

//! Blob descriptor
Expand All @@ -167,11 +173,11 @@ struct column_info<ColumnT, typename std::enable_if<
return ColumnDataType::blob_t;
}
using value_type = Blob;
static constexpr bool is_fixed_size = std::is_pod<ColumnT>::value;
static constexpr bool is_fixed_size = is_pod<ColumnT>::value;
};

//! See if the given column data type has a fixed number
//! of bytes, as determined by std::is_pod<T>
//! of bytes, as determined by is_pod<T>
inline bool getColumnIsFixedSize(const ColumnDataType dtype)
{
using dt = ColumnDataType;
Expand Down
3 changes: 2 additions & 1 deletion sparta/simdb/src/ObjectRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ PropertyDataT LOCAL_getScalarProperty(const std::string & table_name,
//! without using ObjectQuery.
template <typename PropertyDataT>
typename std::enable_if<
std::is_pod<PropertyDataT>::value,
std::is_trivial<PropertyDataT>::value &&
std::is_standard_layout<PropertyDataT>::value,
PropertyDataT>::type
LOCAL_getScalarPropertyNoObjectQuery(
const std::string & table_name,
Expand Down
3 changes: 2 additions & 1 deletion sparta/sparta/pairs/SpartaKeyPairs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,8 @@ namespace sparta {
template<typename T>
MetaStruct::enable_if_t<
std::is_integral<MetaStruct::decay_t<T>>::value &&
std::is_pod<MetaStruct::decay_t<T>>::value &&
std::is_trivial<MetaStruct::decay_t<T>>::value &&
std::is_standard_layout<MetaStruct::decay_t<T>>::value &&
!MetaStruct::is_bool<MetaStruct::decay_t<T>>::value, void>

updateValueInCache_(
Expand Down
4 changes: 2 additions & 2 deletions sparta/sparta/simulation/StateTracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace sparta {
const std::weak_ptr<StatePool<T>> & weak_pool) :
weak_pool_ptr_(weak_pool) {}

StateTrackerDeleter<T>() : valid_(false) {}
StateTrackerDeleter() : valid_(false) {}

inline void operator()(StateTrackerUnit<T> * ptr) const {
if(!valid_ || !ptr) {
Expand Down Expand Up @@ -178,7 +178,7 @@ namespace sparta {

//! The Default Ctor is deleted because StatePool cannot be created
// without a valid state tracking filename.
StatePool<T>() = delete;
StatePool() = delete;

//! A file name is a must when constructing StatePool.
explicit StatePool<T>(const std::string & tracking_filename) :
Expand Down

0 comments on commit 8291100

Please sign in to comment.