Support constructing StringPiece from std::string_view.

Change-Id: I12ea795d2ff0aae99683ceb9afeb2569941b4dbf
Reviewed-on: https://code-review.googlesource.com/c/37631
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/re2/stringpiece.h b/re2/stringpiece.h
index 1db7a2a..0181671 100644
--- a/re2/stringpiece.h
+++ b/re2/stringpiece.h
@@ -19,12 +19,20 @@
 //
 // Arghh!  I wish C++ literals were "string".
 
+// Doing this simplifies the logic below.
+#ifndef __has_include
+#define __has_include(x) 0
+#endif
+
 #include <stddef.h>
 #include <string.h>
 #include <algorithm>
 #include <iosfwd>
 #include <iterator>
 #include <string>
+#if __has_include(<string_view>)
+#include <string_view>
+#endif
 
 namespace re2 {
 
@@ -49,6 +57,10 @@
   // expected.
   StringPiece()
       : data_(NULL), size_(0) {}
+#if __has_include(<string_view>)
+  StringPiece(const std::string_view& str)
+      : data_(str.data()), size_(str.size()) {}
+#endif
   StringPiece(const std::string& str)
       : data_(str.data()), size_(str.size()) {}
   StringPiece(const char* str)