Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Followup to 4355: eliminate the macro #4376

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions tiledb/sm/cpp_api/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* The MIT License
*
* @copyright Copyright (c) 2017-2021 TileDB, Inc.
* @copyright Copyright (c) 2017-2023 TileDB, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -47,8 +47,6 @@
#include <type_traits>
#include <vector>

#define IS_TRIVIALLY_COPYABLE(T) std::is_trivially_copyable<T>::value

namespace tiledb {

namespace impl {
Expand All @@ -59,23 +57,24 @@ struct defer_assert : std::false_type {};

/** Used to statically type check for std::array. */
template <typename T>
struct is_stl_array : std::false_type {};
struct is_std_array : std::false_type {};
template <typename T, std::size_t N>
struct is_stl_array<std::array<T, N>> : std::true_type {};
struct is_std_array<std::array<T, N>> : std::true_type {};

/** SFINAE handler for types that make sense to be bitwise copied. **/
template <typename T>
using enable_trivial = typename std::enable_if<
IS_TRIVIALLY_COPYABLE(T) && !std::is_pointer<T>::value &&
!std::is_array<T>::value && !is_stl_array<T>::value>::type;
std::is_trivially_copyable_v<T> && !std::is_pointer_v<T> &&
!std::is_array_v<T> && !is_std_array<T>::value>::type;

/**
* Convert a type into a tiledb_datatype_t. The default for all
* copyable types is char.
*/
template <typename T>
struct type_to_tiledb {
static_assert(IS_TRIVIALLY_COPYABLE(T), "Type must be trivially copyable.");
static_assert(
std::is_trivially_copyable_v<T>, "Type must be trivially copyable.");
using type = char;
static const tiledb_datatype_t tiledb_type = TILEDB_STRING_ASCII;
static constexpr const char* name = "Trivially Copyable (CHAR)";
Expand Down
Loading