Add `OptionalCompactString::value()`, like `operator*` but with a runtime check
against nullptr.

PiperOrigin-RevId: 936468053
diff --git a/riegeli/base/optional_compact_string.h b/riegeli/base/optional_compact_string.h
index 30775c8..aca8fcb 100644
--- a/riegeli/base/optional_compact_string.h
+++ b/riegeli/base/optional_compact_string.h
@@ -126,6 +126,16 @@
     return CompactString::ViewFromRaw(&repr_);
   }
 
+  // Views the value as an `absl::string_view`.
+  //
+  // Precondition: `*this != nullptr`.
+  absl::string_view value() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
+    RIEGELI_CHECK(*this != nullptr)
+        << "Failed precondition of OptionalCompactString::value(): "
+           "OptionalCompactString is nullptr";
+    return CompactString::ViewFromRaw(&repr_);
+  }
+
   ArrowProxy<absl::string_view> operator->() const
       ABSL_ATTRIBUTE_LIFETIME_BOUND {
     RIEGELI_ASSERT(*this != nullptr)