Skip to content

Commit

Permalink
Don't use 1-argument form of static_assert
Browse files Browse the repository at this point in the history
static_assert requires C++17 to use the 1-argument
form. Use the 2-argument form instead since we
only require C++11 for now.
  • Loading branch information
benmwebb committed Feb 2, 2024
1 parent 1891469 commit 3ad9cdf
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions include/RMF/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ class Vector
RMF_CXX11_DEFAULT_COPY_CONSTRUCTOR(Vector);

Vector(float x, float y, float z) {
static_assert(D == 3);
static_assert(D == 3, "Constructor only valid for Vector3");
P::operator[](0) = x;
P::operator[](1) = y;
P::operator[](2) = z;
}
Vector(float x, float y, float z, float q) {
static_assert(D == 4);
static_assert(D == 4, "Constructor only valid for Vector4");
P::operator[](0) = x;
P::operator[](1) = y;
P::operator[](2) = z;
Expand Down
6 changes: 3 additions & 3 deletions include/RMF/internal/swig_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ struct ValueOrObject {

template <class T>
struct ConvertAllBase {
static_assert(!is_pointer<T>::value);
static_assert(!is_pointer<T>::value, "is a pointer");
template <class SwigData>
static bool get_is_cpp_object(PyObject* o, SwigData st) {
void* vp;
Expand All @@ -129,7 +129,7 @@ struct ConvertAllBase {

template <class T>
struct ConvertValueBase : public ConvertAllBase<T> {
static_assert(!is_pointer<T>::value);
static_assert(!is_pointer<T>::value, "is a pointer");
template <class SwigData>
static const T& get_cpp_object(PyObject* o, SwigData st) {
void* vp;
Expand Down Expand Up @@ -175,7 +175,7 @@ struct Convert : public ConvertValueBase<T> {
template <class T, class VT, class ConvertVT>
struct ConvertSequenceHelper {
typedef typename ValueOrObject<VT>::type V;
static_assert(!is_pointer<T>::value);
static_assert(!is_pointer<T>::value, "is a pointer");
template <class SwigData>
static bool get_is_cpp_object(PyObject* in, SwigData st) {
if (!in || !PySequence_Check(in)) {
Expand Down
4 changes: 2 additions & 2 deletions src/avrocpp/api/AvroParse.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ void parse(ResolvingReader &p, T &val) {

template <typename Reader, typename T>
void parse(Reader &p, T &val, const boost::false_type &) {
static_assert(sizeof(T) == 0);
static_assert(sizeof(T) == 0, "val should be empty");
}

template <typename Reader, typename T>
void translatingParse(Reader &p, T &val, const boost::false_type &) {
static_assert(sizeof(T) == 0);
static_assert(sizeof(T) == 0, "val should be empty");
}

// @{
Expand Down
2 changes: 1 addition & 1 deletion src/avrocpp/api/AvroSerialize.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void serialize(Writer &s, const T &val) {

template <typename Writer, typename T>
void serialize(Writer &s, const T &val, const boost::false_type &) {
static_assert(sizeof(T) == 0);
static_assert(sizeof(T) == 0, "val should be empty");
}

/// The remainder of the file includes default implementations for serializable
Expand Down
2 changes: 1 addition & 1 deletion src/avrocpp/api/buffer/BufferReader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class AVRO_DECL BufferReader : private boost::noncopyable {
/// An uninstantiable function, this is if boost::is_fundamental check fails
template <typename T>
bool read(T &val, const boost::false_type &) {
static_assert(sizeof(T) == 0);
static_assert(sizeof(T) == 0, "val should be empty");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/avrocpp/api/buffer/detail/BufferDetail.hh
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class BufferImpl : boost::noncopyable {
/// and will compile-time assert.
template <typename T>
void writeTo(T val, const boost::false_type &) {
static_assert(sizeof(T) == 0);
static_assert(sizeof(T) == 0, "val should be empty");
}

/// Write a block of data to the buffer, adding new chunks if necessary.
Expand Down
4 changes: 2 additions & 2 deletions src/avrocpp/impl/Resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ class ResolverFactory : private boost::noncopyable {
&ResolverFactory::constructCompound<FixedParser, FixedSkipper>};

static_assert((sizeof(funcs) / sizeof(BuilderFunc)) ==
(AVRO_NUM_TYPES));
(AVRO_NUM_TYPES), "function table size mismatch");

BuilderFunc func = funcs[currentWriter->type()];
assert(func);
Expand Down Expand Up @@ -595,7 +595,7 @@ class ResolverFactory : private boost::noncopyable {
&ResolverFactory::constructCompoundSkipper<FixedSkipper>};

static_assert((sizeof(funcs) / sizeof(BuilderFunc)) ==
(AVRO_NUM_TYPES));
(AVRO_NUM_TYPES), "function table size mismatch");

BuilderFunc func = funcs[currentWriter->type()];
assert(func);
Expand Down
4 changes: 2 additions & 2 deletions src/avrocpp/impl/Types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ const std::string typeToString[] = {
"record", "enum", "array", "map", "union", "fixed", "symbolic"};

static_assert((sizeof(typeToString) / sizeof(std::string)) ==
(AVRO_NUM_TYPES + 1));
(AVRO_NUM_TYPES + 1), "type table size mismatch");

} // namespace strings

// this static assert exists because a 32 bit integer is used as a bit-flag for
// each type,
// and it would be a problem for this flag if we ever supported more than 32
// types
static_assert(AVRO_NUM_TYPES < 32);
static_assert(AVRO_NUM_TYPES < 32, "flags should fit in 32-bit");

const std::string &toString(Type type) {
static std::string undefinedType = "Undefined type";
Expand Down
5 changes: 3 additions & 2 deletions src/avrocpp/impl/Validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void Validator::doAdvance() {
&Validator::countingAdvance, &Validator::unionAdvance,
&Validator::fixedAdvance};
static_assert((sizeof(funcs) / sizeof(AdvanceFunc)) ==
(AVRO_NUM_TYPES));
(AVRO_NUM_TYPES), "function table size mismatch");

expectedTypesFlag_ = 0;
// loop until we encounter a next expected type, or we've exited all compound
Expand Down Expand Up @@ -197,7 +197,8 @@ void Validator::setupFlag(Type type) {
typeToFlag(AVRO_ENUM), typeToFlag(AVRO_ARRAY),
typeToFlag(AVRO_MAP), typeToFlag(AVRO_UNION),
typeToFlag(AVRO_FIXED)};
static_assert((sizeof(flags) / sizeof(flag_t)) == (AVRO_NUM_TYPES));
static_assert((sizeof(flags) / sizeof(flag_t)) == (AVRO_NUM_TYPES),
"flags table size mismatch");

expectedTypesFlag_ = flags[type];
}
Expand Down

0 comments on commit 3ad9cdf

Please sign in to comment.