Specify extern template for StringDataTemplate.
The code is already all in the .cpp file, so we can perhaps
avoid having the compiler emit extra definitions when the header
is included.
- Remove ifdefs in string_view_template.h, as the extern template
pattern is is full use elsewhere already,
Change-Id: I81e91577801b22af6b5e765342c45a1d0f880a9d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/89150
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/string_data_template.h b/core/fxcrt/string_data_template.h
index f311e6c..c49b2bc 100644
--- a/core/fxcrt/string_data_template.h
+++ b/core/fxcrt/string_data_template.h
@@ -50,6 +50,9 @@
~StringDataTemplate() = delete;
};
+extern template class StringDataTemplate<char>;
+extern template class StringDataTemplate<wchar_t>;
+
} // namespace fxcrt
using fxcrt::StringDataTemplate;
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index 7d5d398..4c49877 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -286,12 +286,8 @@
return rhs > lhs;
}
-// Workaround for one of the cases external template classes are
-// failing in GCC before version 7 with -O0
-#if !defined(__GNUC__) || __GNUC__ >= 7
extern template class StringViewTemplate<char>;
extern template class StringViewTemplate<wchar_t>;
-#endif
using ByteStringView = StringViewTemplate<char>;
using WideStringView = StringViewTemplate<wchar_t>;