pw_span: Include system span header only if fresh enough

Before this CL polyfill span was always included and relied on the
__cpp_lib_span define. Some older standard libraries could have this one
not defined which leads to ambiguity during compilation.
This CL fetches __cpp_lib_span version first and includes system span
header only if version is good enough, otherwise it fall backs to custom
implementation.

Change-Id: Ia20e649a2893259929f500154e2d74366feb2ca4
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/99540
Reviewed-by: Wyatt Hepler <hepler@google.com>
Pigweed-Auto-Submit: Dennis Kormalev <denk@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_span/public_overrides/span b/pw_span/public_overrides/span
index 1ac4288..715f155 100644
--- a/pw_span/public_overrides/span
+++ b/pw_span/public_overrides/span
@@ -13,8 +13,16 @@
 // the License.
 #pragma once
 
-#if __has_include_next(<span>)
-#include_next <span>
-#endif  // __has_include_next(<span>)
+#if __has_include(<version>)
+#include <version>
+#endif  // __has_include(<version>)
 
+// We are using <span> only if we were able to fetch __cpp_lib_span from
+// <version> and it is at least 202002. In all other cases we are using
+// custom span implementation.
+#if defined(__cpp_lib_span) && __cpp_lib_span >= 202002L
+#include_next <span>
+#else
+#undef __cpp_lib_span
 #include "pw_span/internal/span.h"
+#endif  // defined(__cpp_lib_span) && __cpp_lib_span >= 202002L