mirror of
https://github.com/fmtlib/fmt.git
synced 2025-12-09 18:26:57 +08:00
* Update format.cc
As the explicit instantiation *declaration* of `internal::basic_data<void>` in format.h, this explicit instantiation *definition* should mirror FMT_API also.
* Mirror visibility of explicit instantiation declaration
explicit instantiation declaration of internal::basic_data<void> should mirror visibility of FMT_API
* Eliminate `__declspec(dllexport)` designation on extern template internal::basic_data<> when `extern` affected during exporting phase.
* Add `FMT_EXTERN_TEMPLATE_API` for designate DLL export `extern template`
When exporting DLL, do not designate `__declspec(dllexport)` any template that has any explicit class template declaration a.k.a. `extern template`. Instead, designate `__declspec(dllexport)` at single point where we have explicit class template definition a.k.a. normal instantiation without `extern`
Note: this is a c++11 feature.
* Delete whole `FMT_USE_EXTERN_TEMPLATES` block and its condition
1. Remove whole `FMT_USE_EXTERN_TEMPLATES` block
(trailing `FMT_UDL_TEMPLATE` block)
````
#ifndef FMT_USE_EXTERN_TEMPLATES
# ifndef FMT_HEADER_ONLY
# define FMT_USE_EXTERN_TEMPLATES \
((FMT_CLANG_VERSION >= 209 && __cplusplus >= 201103L) || \
(FMT_GCC_VERSION >= 303 && FMT_HAS_GXX_CXX11))
# else
# define FMT_USE_EXTERN_TEMPLATES 0
# endif
#endif
````
2. Delete `FMT_USE_EXTERN_TEMPLATES` condition, only condition, that trailing basic_data class template definition.
````
#if FMT_USE_EXTERN_TEMPLATES
extern template struct basic_data<void>;
#endif
````
3. Replace `FMT_API` with new `FMT_EXTERN_TEMPLATE_API` added in `core.h` for sake of extern template of `basic_data<void>`
* Add `#define FMT_EXTERN extern` only when not `FMT_HEADER_ONLY`
* Replace `extern` on basic_data<void> with the `FMT_EXTERN` condition in core.h
* replace misspelled if !define() with ifndef
56 lines
2.0 KiB
C++
56 lines
2.0 KiB
C++
// Formatting library for C++
|
|
//
|
|
// Copyright (c) 2012 - 2016, Victor Zverovich
|
|
// All rights reserved.
|
|
//
|
|
// For the license information refer to format.h.
|
|
|
|
#include "fmt/format-inl.h"
|
|
|
|
FMT_BEGIN_NAMESPACE
|
|
template struct FMT_API internal::basic_data<void>;
|
|
|
|
// Workaround a bug in MSVC2013 that prevents instantiation of grisu_format.
|
|
bool (*instantiate_grisu_format)(double, internal::buffer<char>&, int, unsigned,
|
|
int&) = internal::grisu_format;
|
|
|
|
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
|
template FMT_API internal::locale_ref::locale_ref(const std::locale& loc);
|
|
template FMT_API std::locale internal::locale_ref::get<std::locale>() const;
|
|
#endif
|
|
|
|
// Explicit instantiations for char.
|
|
|
|
template FMT_API char internal::thousands_sep_impl(locale_ref);
|
|
|
|
template FMT_API void internal::buffer<char>::append(const char*, const char*);
|
|
|
|
template FMT_API void internal::arg_map<format_context>::init(
|
|
const basic_format_args<format_context>& args);
|
|
|
|
template FMT_API std::string internal::vformat<char>(
|
|
string_view, basic_format_args<format_context>);
|
|
|
|
template FMT_API format_context::iterator internal::vformat_to(
|
|
internal::buffer<char>&, string_view, basic_format_args<format_context>);
|
|
|
|
template FMT_API void internal::sprintf_format(double, internal::buffer<char>&,
|
|
core_format_specs);
|
|
template FMT_API void internal::sprintf_format(long double,
|
|
internal::buffer<char>&,
|
|
core_format_specs);
|
|
|
|
// Explicit instantiations for wchar_t.
|
|
|
|
template FMT_API wchar_t internal::thousands_sep_impl(locale_ref);
|
|
|
|
template FMT_API void internal::buffer<wchar_t>::append(const wchar_t*,
|
|
const wchar_t*);
|
|
|
|
template FMT_API void internal::arg_map<wformat_context>::init(
|
|
const basic_format_args<wformat_context>&);
|
|
|
|
template FMT_API std::wstring internal::vformat<wchar_t>(
|
|
wstring_view, basic_format_args<wformat_context>);
|
|
FMT_END_NAMESPACE
|