Add non-const operator[] to TypedIOBuf
authorTudor Bosman <tudorb@fb.com>
Tue, 15 Apr 2014 16:24:11 +0000 (09:24 -0700)
committerSara Golemon <sgolemon@fb.com>
Fri, 18 Apr 2014 19:04:15 +0000 (12:04 -0700)
Test Plan: used it

Reviewed By: lucian@fb.com

FB internal diff: D1277063

@override-unit-failures

folly/io/TypedIOBuf.h

index 26eccccca8e3ec2ebc97828ebb4118e97607be91..c5ecfc484837502d1c8ec6536e9882c15cc0800e 100644 (file)
@@ -153,6 +153,11 @@ class TypedIOBuf {
     return data()[idx];
   }
 
+  T& operator[](ssize_t idx) {
+    assert(idx >= 0 && idx < length());
+    return writableData()[idx];
+  }
+
   /**
    * Append one element.
    */