Paul Wankadia has uploaded this change for review.
Document why `RE2` objects are neither copyable nor movable.
Change-Id: Icf86a2e12f4f860bd6406b1326324d987659413f
---
M re2/re2.h
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/re2/re2.h b/re2/re2.h
index 4699a7d..d604f1c 100644
--- a/re2/re2.h
+++ b/re2/re2.h
@@ -280,6 +280,20 @@
RE2(const StringPiece& pattern, const Options& options);
~RE2();
+ // Not copyable.
+ // RE2 objects are expensive. You should probably use std::shared_ptr<RE2>
+ // instead. If you really must copy, RE2(first.pattern(), first.options())
+ // effectively does so: it produces a second object that mimics the first.
+ RE2(const RE2&) = delete;
+ RE2& operator=(const RE2&) = delete;
+ // Not movable.
+ // RE2 objects are thread-safe and logically immutable. You should probably
+ // use std::unique_ptr<RE2> instead. Otherwise, consider std::deque<RE2> if
+ // direct emplacement into a container is desired. If you really must move,
+ // be prepared to submit a design document along with your feature request.
+ RE2(RE2&&) = delete;
+ RE2& operator=(RE2&&) = delete;
+
// Returns whether RE2 was created properly.
bool ok() const { return error_code() == NoError; }
@@ -777,9 +791,6 @@
mutable std::once_flag rprog_once_;
mutable std::once_flag named_groups_once_;
mutable std::once_flag group_names_once_;
-
- RE2(const RE2&) = delete;
- RE2& operator=(const RE2&) = delete;
};
/***** Implementation details *****/
To view, visit change 60410. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Paul Wankadia.
Patch set 1:Code-Review +1
Patch set 1:Code-Review +2
Paul Wankadia submitted this change.
Document why `RE2` objects are neither copyable nor movable.
Change-Id: Icf86a2e12f4f860bd6406b1326324d987659413f
Reviewed-on: https://code-review.googlesource.com/c/re2/+/60410
Reviewed-by: Perry Lorier <per...@google.com>
Reviewed-by: Paul Wankadia <jun...@google.com>
---
M re2/re2.h
1 file changed, 26 insertions(+), 3 deletions(-)
To view, visit change 60410. To unsubscribe, or for help writing mail filters, visit settings.