perfetto: switch to C++17 with temporary C++11 opt-out

* make all targets build with C++17
* make it an error to compile with C++11 without defining an opt-out
  flag. The error makes it clear that any objections need to be
  discussed very soon
* Keep the debug CI bot compiling with C++11 to prevent accidental
  use of C++14/17 features in the transition period

Bug: b/257064316
Change-Id: I32c227944f9d65a110d4f613b1ea17a823567822
diff --git a/gn/standalone/BUILD.gn b/gn/standalone/BUILD.gn
index 0d17328..192bee8 100644
--- a/gn/standalone/BUILD.gn
+++ b/gn/standalone/BUILD.gn
@@ -111,6 +111,10 @@
 }
 
 config("c++11") {
+  if (!perfetto_cpp11_until_q1_2023) {
+    visibility = []
+  }
+
   # C++11 is the default on Windows.
   if (!is_win) {
     cflags_cc = [ "-std=c++11" ]
@@ -118,11 +122,16 @@
     # Enable standards-conforming compiler behavior.
     cflags_cc = [ "/permissive-" ]
   }
+  defines = [ "PERFETTO_ALLOW_SUB_CPP17" ]
 }
 
 # Used in buildtools dependencies for standalone builds.
 config("c++14") {
-  visibility = [ "//buildtools:llvm_demangle" ]
+  if (perfetto_cpp11_until_q1_2023) {
+    visibility = [ "//buildtools:llvm_demangle" ]
+  } else {
+    visibility = []
+  }
   if (is_win) {
     cflags_cc = [ "/std:c++14" ]
   } else {
@@ -132,7 +141,9 @@
 
 # Used in buildtools dependencies for standalone builds.
 config("c++17") {
-  visibility = [ "//buildtools:libunwindstack" ]
+  if (perfetto_cpp11_until_q1_2023) {
+    visibility = [ "//buildtools:libunwindstack" ]
+  }
   if (is_win) {
     cflags_cc = [ "/std:c++17" ]
   } else {
@@ -196,6 +207,7 @@
       "/Gy",  # Enable function-level linking.
       "/FS",  # Preserve previous PDB behavior.
       "/utf-8",  # Assume UTF-8 by default to avoid code page dependencies.
+      "/Zc:__cplusplus",  # Allow use of __cplusplus macro.
     ]
     defines += [
       "_CRT_NONSTDC_NO_WARNINGS",