Summary:
As described in the comment in `folly/stats/Histogram.h`, MSVC 2017.3 has issues with `/permissive-`.
The bug has been fixed upstream, it's just waiting for release.
These explicit template instantiations are never forward-declared anywhere, so, as long as `Histogram-defs.h` has been included, it's perfectly safe to just not do them.
https://developercommunity.visualstudio.com/content/problem/81223/incorrect-error-c5037-with-permissive.html
Reviewed By: yfeldblum
Differential Revision:
D5828891
fbshipit-source-id:
4db8407c9d35aa5bb3f7b81aa24f611b5787fb6e
#include <folly/stats/Histogram.h>
#include <folly/stats/Histogram-defs.h>
+#if !FOLLY_MSVC_USE_WORKAROUND_FOR_C5037
namespace folly {
template class Histogram<int64_t>;
Histogram<int64_t>::CountFromBucket countFromBucket) const;
} // namespace folly
+#endif
};
} // namespace folly
+
+// MSVC 2017 Update 3 has an issue with explicitly instantiating templated
+// functions with default arguments inside templated classes when compiled
+// with /permissive- (the default for the CMake build), so we directly include
+// the -defs as if it were -inl, and don't provide the explicit instantiations.
+// https://developercommunity.visualstudio.com/content/problem/81223/incorrect-error-c5037-with-permissive.html
+#if defined(_MSC_VER) && _MSC_FULL_VER >= 191125506 && _MSC_FULL_VER < 191125542
+#define FOLLY_MSVC_USE_WORKAROUND_FOR_C5037 1
+#else
+#define FOLLY_MSVC_USE_WORKAROUND_FOR_C5037 0
+#endif
+
+#if FOLLY_MSVC_USE_WORKAROUND_FOR_C5037
+#include <folly/stats/Histogram-defs.h>
+#endif