From 3fc03e42ce73021c4573729a637d19346f7e5f44 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 8 Jan 2019 16:33:31 -0800 Subject: [PATCH] [iter] Use static_assert with hb_is_random_access_iterator() Both, checks constexpr'ness, and fixes build with cra**y implementations of assert() macro: test-iter.cc:108:11: error: too many arguments provided to function-like macro invocation assert (hb_is_random_access_iterator (array_iter_t)); ^ ./hb-iter.hh:186:42: note: expanded from macro 'hb_is_random_access_iterator' hb_is_random_access_iterator_of (Iter, typename Iter::item_t) ^ /usr/include/x86_64-linux-gnu/sys/cdefs.h:89:9: note: macro '__STRING' defined here \#define __STRING(x) #x ^ test-iter.cc:108:3: error: use of undeclared identifier '__STRING' assert (hb_is_random_access_iterator (array_iter_t)); ^ /usr/include/assert.h:91:21: note: expanded from macro 'assert' : __assert_fail (__STRING(expr), __FILE__, __LINE__, __ASSERT_FUNCTION)) ^ --- src/test-iter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test-iter.cc b/src/test-iter.cc index 5836551..33bf4b4 100644 --- a/src/test-iter.cc +++ b/src/test-iter.cc @@ -105,7 +105,7 @@ main (int argc, char **argv) array_iter_t s2 (v); /* Implicit conversion from vector. */ array_iter_t t (dst); - assert (hb_is_random_access_iterator (array_iter_t)); + static_assert (hb_is_random_access_iterator (array_iter_t), ""); some_array_t a (src); -- 2.7.4