Add payloads() accessor to StatusRep and include <optional> in status.cc.

PiperOrigin-RevId: 996172950
Change-Id: I40a4772c56214b00a3cb7a6885ad5f2389d98a05
diff --git a/absl/status/internal/status_internal.h b/absl/status/internal/status_internal.h
index 3bd7b1b..07a5679 100644
--- a/absl/status/internal/status_internal.h
+++ b/absl/status/internal/status_internal.h
@@ -112,6 +112,11 @@
       absl::FunctionRef<void(absl::string_view, const absl::Cord&)> visitor)
       const;
 
+  // Returns the raw payload list, or nullptr if there are none. Unlike
+  // `ForEachPayload`, this does not hide `kStackTraceUrl` payloads and does not
+  // invalidate `type_url` lifetimes in debug builds; callers must handle both.
+  const Payloads* absl_nullable payloads() const { return payloads_.get(); }
+
   absl::Span<const SourceLocation> GetSourceLocations() const;
   void AddSourceLocation(absl::SourceLocation loc);
 
diff --git a/absl/status/status.cc b/absl/status/status.cc
index 32c8415..bb03157 100644
--- a/absl/status/status.cc
+++ b/absl/status/status.cc
@@ -18,6 +18,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <memory>
+#include <optional>
 #include <ostream>
 #include <string>
 #include <type_traits>