[PyTorch][easy] Add cbegin/cend to SmallVector (#64682)
authorScott Wolchok <swolchok@fb.com>
Wed, 15 Sep 2021 16:55:02 +0000 (09:55 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 15 Sep 2021 16:57:56 +0000 (09:57 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/64682

Looks like it was forked from llvm before cbegin and cend existed.
ghstack-source-id: 138036981

Test Plan: CI

Reviewed By: dhruvbird

Differential Revision: D30814434

fbshipit-source-id: 9740fa8d3df1c90b77298a95ab9f1d0cf8c90320

c10/util/SmallVector.h

index 38b2653..5684263 100644 (file)
@@ -139,12 +139,18 @@ class SmallVectorTemplateCommon : public SmallVectorBase {
     return (iterator)this->BeginX;
   }
   const_iterator begin() const {
+    return cbegin();
+  }
+  const_iterator cbegin() const {
     return (const_iterator)this->BeginX;
   }
   iterator end() {
     return (iterator)this->EndX;
   }
   const_iterator end() const {
+    return cend();
+  }
+  const_iterator cend() const {
     return (const_iterator)this->EndX;
   }