Fix CUDA 8 build on Windows (#14665)
authorpeter <peterghost86@gmail.com>
Sun, 2 Dec 2018 00:47:57 +0000 (16:47 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sun, 2 Dec 2018 00:50:38 +0000 (16:50 -0800)
Summary:
Fixes #14663.
Test for CUDA 8 is running here: https://dev.azure.com/pytorch/PyTorch/_build/results?buildId=54
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14665

Differential Revision: D13290392

Pulled By: soumith

fbshipit-source-id: 57f0d5b704e5d1fcb4927cbc007327b4ed74f443

c10/util/Optional.h

index 87bb3de..9eb89a2 100644 (file)
@@ -150,6 +150,13 @@ inline constexpr typename std::remove_reference<T>::type&& constexpr_move(
 
 namespace detail_ {
 
+// VS 2015 doesn't handle constexpr well, so we need to skip these stuff.
+#if (defined _MSC_VER) && (_MSC_VER <= 1900)
+template <typename T>
+T* static_addressof(T& ref) {
+  return std::addressof(ref);
+}
+#else
 // static_addressof: a constexpr version of addressof
 template <typename T>
 struct has_overloaded_addressof {
@@ -175,6 +182,7 @@ template <typename T, TR2_OPTIONAL_REQUIRES(has_overloaded_addressof<T>)>
 T* static_addressof(T& ref) {
   return std::addressof(ref);
 }
+#endif
 
 // the call to convert<A>(b) has return type A and converts b to type A iff b
 // decltype(b) is implicitly convertible to A