Commit 7eaace04 authored by Andrei Alexandrescu's avatar Andrei Alexandrescu Committed by Sara Golemon

Disallow assignment to rvalue Range objects (and StringPiece in particular)

Summary:
Before this diff the code below compiled and did absolutely nothing of interest:

StringPiece fun();
...
fun() = "hello";

i.e. assignment to an rvalue range was allowed. Such code is almost always, if not always, in error. This diff fixes that.

Test Plan: ran unittests

Reviewed By: ldbrandy@fb.com

Subscribers: mpawlowski, net-systems@, folly-diffs@, yfeldblum

FB internal diff: D1825360

Signature: t1:1825360:1423097817:fdaaf893cd1abbe71dc857a315df7c45cb6a0bd0
parent 5079904b
...@@ -184,6 +184,9 @@ public: ...@@ -184,6 +184,9 @@ public:
constexpr Range() : b_(), e_() { constexpr Range() : b_(), e_() {
} }
constexpr Range(const Range&) = default;
constexpr Range(Range&&) = default;
public: public:
// Works for all iterators // Works for all iterators
constexpr Range(Iter start, Iter end) : b_(start), e_(end) { constexpr Range(Iter start, Iter end) : b_(start), e_(end) {
...@@ -322,6 +325,9 @@ public: ...@@ -322,6 +325,9 @@ public:
e_(other.end()) { e_(other.end()) {
} }
Range& operator=(const Range& rhs) & = default;
Range& operator=(Range&& rhs) & = default;
void clear() { void clear() {
b_ = Iter(); b_ = Iter();
e_ = Iter(); e_ = Iter();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment