Add documentation for the `OverlapOf` domain combinator.
PiperOrigin-RevId: 813851281
diff --git a/doc/domains-reference.md b/doc/domains-reference.md
index 3e27442..b3e5e0d 100644
--- a/doc/domains-reference.md
+++ b/doc/domains-reference.md
@@ -994,6 +994,22 @@
Note that the list of domains must be known at compile time; unlike `ElementOf`,
you can't use a vector of domains.
+### OverlapOf
+
+With the `OverlapOf` combinator, we can use multiple domains to constrain a
+single type. The generated values satisfy all of the provided domains. For
+example:
+
+```c++
+auto ConstrainedNonZero() {
+ return OverlapOf(NonZero<int64_t>(), InRange<int64_t>(-355, 355));
+}
+```
+
+`ConstrainedNonZero()` produces integers between -355 and 355, but never 0.
+This may be useful in cases where 0 is silently interpreted as a sentinel value
+(e.g., "not set").
+
### Map
Often the best way to define a domain is using a mapping function. The `Map()`
diff --git a/fuzztest/domain_core.h b/fuzztest/domain_core.h
index b6bf4b8..f0a6a3d 100644
--- a/fuzztest/domain_core.h
+++ b/fuzztest/domain_core.h
@@ -315,7 +315,13 @@
return internal::OneOfImpl<Inner...>(std::move(domains)...);
}
-// TODO(xinhaoyuan): Documentation.
+// OverlapOf(inner...) combinator creates a domain with elements that satisfy
+// the conditions of all `inner` domains.
+//
+// Example usage:
+//
+// OverlapOf(InRange<int>(-10, 10), NonZero<int>())
+//
template <int&... ExplicitArgumentBarrier, typename... Inner>
auto OverlapOf(Inner... domains) {
auto MaybeWrapDomain =