Commit 51d48522 authored by scottmg's avatar scottmg Committed by Commit bot

Move StringComparator<string16>::operator() to header

Enabling /Zc:inline on static release build results in

FAILED: E:\b\depot_tools\python276_bin\python.exe gyp-win-tool link-with-manifests environment.x64 True chrome.dll "E:\b\depot_tools\python276_bin\python.exe gyp-win-tool link-wrapper environment.x64 False link.exe /nologo /IMPLIB:chrome.dll.lib /DLL /OUT:chrome.dll @chrome.dll.rsp" 2 mt.exe rc.exe "obj\chrome\chrome_main_dll.chrome.dll.intermediate.manifest" obj\chrome\chrome_main_dll.chrome.dll.generated.manifest ..\..\chrome\app\chrome.dll.manifest
browser_2.lib(browser_2.character_encoding.obj) : error LNK2019: unresolved external symbol "public: bool __cdecl l10n_util::StringComparator<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > >::operator()(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (??R?$StringComparator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@l10n_util@@QEAA_NAEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@0@Z) referenced in function "void __cdecl std::_Adjust_heap<struct CharacterEncoding::EncodingInfo *,__int64,struct CharacterEncoding::EncodingInfo,class l10n_util::StringComparator<struct CharacterEncoding::EncodingInfo> >(struct CharacterEncoding::EncodingInfo *,__int64,__int64,struct CharacterEncoding::EncodingInfo &&,class l10n_util::StringComparator<struct CharacterEncoding::EncodingInfo>)" (??$_Adjust_heap@PEAUEncodingInfo@CharacterEncoding@@_JU12@V?$StringComparator@UEncodingInfo@CharacterEncoding@@@l10n_util@@@std@@YAXPEAUEncodingInfo@CharacterEncoding@@_J1$$QEAU12@V?$StringComparator@UEncodingInfo@CharacterEncoding@@@l10n_util@@@Z)

browser_1.lib(browser_1.background_application_list_model.obj) : error LNK2001: unresolved external symbol "public: bool __cdecl l10n_util::StringComparator<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > >::operator()(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (??R?$StringComparator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@l10n_util@@QEAA_NAEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@0@Z)

So, move StringComparator<base::string16>::operator() into header and
mark it inline, so that it's available in all translation units where it's
used. The previous code was correct, but this makes all compilers happy.

/Zc:inline ref: http://msdn.microsoft.com/en-us/library/dn642448.aspx

R=rnk@chromium.org
TBR=jshin@chromium.org
BUG=350018

Review URL: https://codereview.chromium.org/518533002

Cr-Commit-Position: refs/heads/master@{#292559}
parent 9ea140f4
......@@ -824,18 +824,6 @@ base::string16 GetStringFUTF16Int(int message_id, int64 a) {
return GetStringFUTF16(message_id, base::UTF8ToUTF16(base::Int64ToString(a)));
}
// Specialization of operator() method for base::string16 version.
template <>
bool StringComparator<base::string16>::operator()(const base::string16& lhs,
const base::string16& rhs) {
// If we can not get collator instance for specified locale, just do simple
// string compare.
if (!collator_)
return lhs < rhs;
return base::i18n::CompareString16WithCollator(collator_, lhs, rhs) ==
UCOL_LESS;
};
base::string16 GetPluralStringFUTF16(const std::vector<int>& message_ids,
int number) {
scoped_ptr<icu::PluralFormat> format = BuildPluralFormat(message_ids);
......
......@@ -106,9 +106,17 @@ class StringComparator : public std::binary_function<const Element&,
};
// Specialization of operator() method for base::string16 version.
template <> UI_BASE_EXPORT
bool StringComparator<base::string16>::operator()(const base::string16& lhs,
const base::string16& rhs);
template <>
UI_BASE_EXPORT inline bool StringComparator<base::string16>::operator()(
const base::string16& lhs,
const base::string16& rhs) {
// If we can not get collator instance for specified locale, just do simple
// string compare.
if (!collator_)
return lhs < rhs;
return base::i18n::CompareString16WithCollator(collator_, lhs, rhs) ==
UCOL_LESS;
}
// In place sorting of |elements| of a vector according to the string key of
// each element in the vector by using collation rules for |locale|.
......
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