File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -544,6 +544,8 @@ private:
544
544
545
545
class StrBlobPtr
546
546
{
547
+ friend bool operator==(const StrBlobPtr&,const StrBlobPtr&);
548
+ friend bool operator!=(const StrBlobPtr&,const StrBlobPtr&);
547
549
public:
548
550
StrBlobPtr() :curr(0) {}
549
551
StrBlobPtr(StrBlob &a, size_t sz = 0) :wptr(a.data), curr(sz) {}
@@ -580,6 +582,17 @@ StrBlobPtr StrBlob::end()
580
582
{
581
583
return StrBlobPtr(*this, data->size());
582
584
}
585
+
586
+ bool operator==(const StrBlobPtr& lhs, const StrBlobPtr& rhs) {
587
+ if (!lhs.wptr.expired() && !rhs.wptr.expired()) {
588
+ return (lhs.wptr.lock() == rhs.wptr.lock()) && (lhs.curr == rhs.curr);
589
+ } else {
590
+ return false;
591
+ }
592
+ }
593
+ bool operator!=(const StrBlobPtr& lhs, const StrBlobPtr& rhs) {
594
+ return !(lhs==rhs);
595
+ }
583
596
```
584
597
585
598
## 练习12.20
You can’t perform that action at this time.
0 commit comments