Commit e35d41ff authored by Victor Zverovich's avatar Victor Zverovich

Add extern templates for format_float (#413)

parent d8c25a17
...@@ -131,6 +131,15 @@ ...@@ -131,6 +131,15 @@
# define FMT_UDL_TEMPLATE 0 # define FMT_UDL_TEMPLATE 0
#endif #endif
#ifndef FMT_USE_EXTERN_TEMPLATES
# ifndef FMT_HEADER_ONLY
# define FMT_USE_EXTERN_TEMPLATES \
(FMT_CLANG_VERSION >= 209 || (FMT_GCC_VERSION >= 303 && FMT_HAS_GXX_CXX11))
# else
# define FMT_USE_EXTERN_TEMPLATES 0
# endif
#endif
#if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clz) #if FMT_GCC_VERSION >= 400 || FMT_HAS_BUILTIN(__builtin_clz)
# define FMT_BUILTIN_CLZ(n) __builtin_clz(n) # define FMT_BUILTIN_CLZ(n) __builtin_clz(n)
#endif #endif
...@@ -513,6 +522,22 @@ class char_traits<wchar_t> : public basic_char_traits<wchar_t> { ...@@ -513,6 +522,22 @@ class char_traits<wchar_t> : public basic_char_traits<wchar_t> {
const wchar_t *format, unsigned width, int precision, T value); const wchar_t *format, unsigned width, int precision, T value);
}; };
#if FMT_USE_EXTERN_TEMPLATES
extern template int char_traits<char>::format_float<double>(
char *buffer, std::size_t size, const char* format, unsigned width,
int precision, double value);
extern template int char_traits<char>::format_float<long double>(
char *buffer, std::size_t size, const char* format, unsigned width,
int precision, long double value);
extern template int char_traits<wchar_t>::format_float<double>(
wchar_t *buffer, std::size_t size, const wchar_t* format, unsigned width,
int precision, double value);
extern template int char_traits<wchar_t>::format_float<long double>(
wchar_t *buffer, std::size_t size, const wchar_t* format, unsigned width,
int precision, long double value);
#endif
template <typename Container> template <typename Container>
inline typename std::enable_if< inline typename std::enable_if<
is_contiguous<Container>::value, typename Container::value_type*>::type is_contiguous<Container>::value, typename Container::value_type*>::type
...@@ -682,13 +707,7 @@ struct FMT_API basic_data { ...@@ -682,13 +707,7 @@ struct FMT_API basic_data {
static const char DIGITS[]; static const char DIGITS[];
}; };
#ifndef FMT_USE_EXTERN_TEMPLATES #if FMT_USE_EXTERN_TEMPLATES
// Clang doesn't have a feature check for extern templates so we check
// for variadic templates which were introduced in the same version.
# define FMT_USE_EXTERN_TEMPLATES (__clang__)
#endif
#if FMT_USE_EXTERN_TEMPLATES && !defined(FMT_HEADER_ONLY)
extern template struct basic_data<void>; extern template struct basic_data<void>;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment