fixed #228 - using an anonymous namespace for the template test registering class and the template function itself is also static
diff --git a/.gitignore b/.gitignore
index cabbd83..457afd6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,3 +34,4 @@
build/
build-mingw/
*.pyc
+*vscode*
diff --git a/doctest/doctest.h b/doctest/doctest.h
index 9b450bb..6c1fa4f 100644
--- a/doctest/doctest.h
+++ b/doctest/doctest.h
@@ -1931,24 +1931,26 @@
#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, iter, func) \
template <typename T> \
- inline void func(); \
- template <typename Tuple> \
- struct iter; \
- template <typename Type, typename... Rest> \
- struct iter<std::tuple<Type, Rest...>> \
- { \
- iter(int line, int index) { \
- DOCTEST_REGISTER_TYPED_TEST_CASE_IMPL(func<Type>, Type, dec, line * 1000 + index); \
- iter<std::tuple<Rest...>>(line, index + 1); \
- } \
- }; \
- template <> \
- struct iter<std::tuple<>> \
- { \
- iter(int, int) {} \
- }; \
+ static void func(); \
+ namespace { \
+ template <typename Tuple> \
+ struct iter; \
+ template <typename Type, typename... Rest> \
+ struct iter<std::tuple<Type, Rest...>> \
+ { \
+ iter(int line, int index) { \
+ DOCTEST_REGISTER_TYPED_TEST_CASE_IMPL(func<Type>, Type, dec, line * 1000 + index); \
+ iter<std::tuple<Rest...>>(line, index + 1); \
+ } \
+ }; \
+ template <> \
+ struct iter<std::tuple<>> \
+ { \
+ iter(int, int) {} \
+ }; \
+ } \
template <typename T> \
- inline void func()
+ static void func()
#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(dec, T, id) \
DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(id, ITERATOR), \
@@ -1982,7 +1984,7 @@
DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(anon, ITERATOR), anon); \
DOCTEST_TEST_CASE_TEMPLATE_INVOKE_IMPL(anon, anon, __VA_ARGS__) \
template <typename T> \
- inline void anon()
+ static void anon()
#define DOCTEST_TEST_CASE_TEMPLATE(dec, T, ...) \
DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), __VA_ARGS__)
diff --git a/doctest/parts/doctest_fwd.h b/doctest/parts/doctest_fwd.h
index e4d4ca7..523c19e 100644
--- a/doctest/parts/doctest_fwd.h
+++ b/doctest/parts/doctest_fwd.h
@@ -1928,24 +1928,26 @@
#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, iter, func) \
template <typename T> \
- inline void func(); \
- template <typename Tuple> \
- struct iter; \
- template <typename Type, typename... Rest> \
- struct iter<std::tuple<Type, Rest...>> \
- { \
- iter(int line, int index) { \
- DOCTEST_REGISTER_TYPED_TEST_CASE_IMPL(func<Type>, Type, dec, line * 1000 + index); \
- iter<std::tuple<Rest...>>(line, index + 1); \
- } \
- }; \
- template <> \
- struct iter<std::tuple<>> \
- { \
- iter(int, int) {} \
- }; \
+ static void func(); \
+ namespace { \
+ template <typename Tuple> \
+ struct iter; \
+ template <typename Type, typename... Rest> \
+ struct iter<std::tuple<Type, Rest...>> \
+ { \
+ iter(int line, int index) { \
+ DOCTEST_REGISTER_TYPED_TEST_CASE_IMPL(func<Type>, Type, dec, line * 1000 + index); \
+ iter<std::tuple<Rest...>>(line, index + 1); \
+ } \
+ }; \
+ template <> \
+ struct iter<std::tuple<>> \
+ { \
+ iter(int, int) {} \
+ }; \
+ } \
template <typename T> \
- inline void func()
+ static void func()
#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(dec, T, id) \
DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(id, ITERATOR), \
@@ -1979,7 +1981,7 @@
DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(anon, ITERATOR), anon); \
DOCTEST_TEST_CASE_TEMPLATE_INVOKE_IMPL(anon, anon, __VA_ARGS__) \
template <typename T> \
- inline void anon()
+ static void anon()
#define DOCTEST_TEST_CASE_TEMPLATE(dec, T, ...) \
DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), __VA_ARGS__)