Fix FBString under MSVC
authorChristopher Dykes <cdykes@fb.com>
Tue, 2 May 2017 01:41:19 +0000 (18:41 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 2 May 2017 01:49:28 +0000 (18:49 -0700)
Summary: MSVC requires the declaration to match a bit closer than GCC does.

Reviewed By: yfeldblum, ot

Differential Revision: D4981404

fbshipit-source-id: 92ee40c40f66725c09a3087e49d99ebae222c2f2

folly/FBString.h

index 45710dc79bbcb40bd52c1f47806d58c831891bcb..c10490abeecfe4ce67953a7066516c7783dde2f6 100644 (file)
@@ -1234,10 +1234,16 @@ public:
   // value_type overload is dangerous, so we're explicitly deleting
   // any overloads of operator= that could implicitly convert to
   // value_type.
   // value_type overload is dangerous, so we're explicitly deleting
   // any overloads of operator= that could implicitly convert to
   // value_type.
+  // Note that we do need to explicitly specify the template types because
+  // otherwise MSVC 2017 will aggressively pre-resolve value_type to
+  // traits_type::char_type, which won't compare as equal when determining
+  // which overload the implementation is referring to.
   template <typename TP>
   typename std::enable_if<
   template <typename TP>
   typename std::enable_if<
-      std::is_same<typename std::decay<TP>::type, value_type>::value,
-      basic_fbstring&>::type
+      std::is_same<
+          typename std::decay<TP>::type,
+          typename basic_fbstring<E, T, A, Storage>::value_type>::value,
+      basic_fbstring<E, T, A, Storage>&>::type
   operator=(TP c);
 
   basic_fbstring& operator=(std::initializer_list<value_type> il) {
   operator=(TP c);
 
   basic_fbstring& operator=(std::initializer_list<value_type> il) {