Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Silence C++17 compatibility warnings on static_assert #2

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion tensorpipe/common/system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ CpuSet makeCpuSet(optional<cpu_set_t> cpus) {
max_cpu_id_online = std::max(max_cpu_id_online, c);
}
}
static_assert(kMaxCpus > 0);
static_assert(kMaxCpus > 0, "!");
if (max_cpu_id_online > kMaxCpus - 1) {
TP_THROW_SYSTEM(ENOTSUP)
<< "Larger online CPU ID found to be " << max_cpu_id_online
Expand Down
2 changes: 1 addition & 1 deletion tensorpipe/common/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ using CpuId = unsigned;
// Used for CPU_* macros and for fixed size per-CPU arrays.
// XXX: Expose this as a configuration parameter.
constexpr unsigned kMaxCpus = 512;
static_assert(kMaxCpus <= CPU_SETSIZE);
static_assert(kMaxCpus <= CPU_SETSIZE, "!");

struct CpuSet {
// Bitset of CPUs.
Expand Down
6 changes: 3 additions & 3 deletions tensorpipe/util/ringbuffer/consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class Consumer : public RingBufferWrapper<THeaderExtraData> {
// Pointer may become invalid in next read or when transaction completes.
template <class T>
std::pair<ssize_t, const T*> readInTx() noexcept {
static_assert(std::is_trivial<T>::value);
static_assert(std::is_standard_layout<T>::value);
static_assert(std::is_trivial<T>::value, "!");
static_assert(std::is_standard_layout<T>::value, "!");

ssize_t ret;
const void* ptr;
Expand Down Expand Up @@ -301,7 +301,7 @@ class Consumer : public RingBufferWrapper<THeaderExtraData> {
/// Makes a copy to <t>.
template <class T>
[[nodiscard]] ssize_t copy(T& t) noexcept {
static_assert(std::is_trivially_copyable<T>::value);
static_assert(std::is_trivially_copyable<T>::value, "!");
return copy(sizeof(T), &t);
}

Expand Down
10 changes: 5 additions & 5 deletions tensorpipe/util/shm/segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Segment {
static_assert(
!std::is_array<T>::value,
"Did you mean to use the array version of Segment::create");
static_assert(std::is_trivially_copyable<T>::value);
static_assert(std::is_trivially_copyable<T>::value, "!");

const auto byte_size = sizeof(T);
auto creation_mode = CreationMode::allPerms(byte_size, link_flags);
Expand Down Expand Up @@ -160,8 +160,8 @@ class Segment {
"You can use the non-template version of Segment::create");

using TScalar = typename std::remove_extent<T>::type;
static_assert(std::is_trivially_copyable<TScalar>::value);
static_assert(!std::is_array<TScalar>::value);
static_assert(std::is_trivially_copyable<TScalar>::value, "!");
static_assert(!std::is_array<TScalar>::value, "!");
static_assert(std::is_same<TScalar[], T>::value, "Type mismatch");

size_t byte_size = sizeof(TScalar) * num_elements;
Expand Down Expand Up @@ -206,7 +206,7 @@ class Segment {
std::rank<T>::value == 1,
"Currently only rank one arrays are supported");
using TScalar = typename std::remove_extent<T>::type;
static_assert(std::is_trivially_copyable<TScalar>::value);
static_assert(std::is_trivially_copyable<TScalar>::value, "!");
// Lambda function to be called by segment shared_ptr destructor.
// Do not delete ptr because it was built in place. Instead, release
// segment to free the shared memory where object T was constructed.
Expand Down Expand Up @@ -241,7 +241,7 @@ class Segment {
}
// Destructor lambda captures a copy to segment's smart pointer and
// will release it when the shared pointer to T is destroyed.
static_assert(std::is_trivially_copyable<T>::value);
static_assert(std::is_trivially_copyable<T>::value, "!");
// Lambda function to be called by segment shared_ptr destructor.
// Do not delete ptr because it was built in place. Instead, release
// segment to free the shared memory where object T was constructed.
Expand Down