Permalink
Browse files

add pop_back to arrays

Summary: Add a pop_back() function to dynamic arrays.

Test Plan: - used it

Reviewed By: delong.j@fb.com

FB internal diff: D569440
  • Loading branch information...
1 parent d0dd99c commit b9836f4a8dc28c2641f027cf47c6604b7268e37f John Fremlin VII committed with jdelong Sep 17, 2012
Showing with 13 additions and 0 deletions.
  1. +5 −0 folly/dynamic-inl.h
  2. +8 −0 folly/dynamic.h
View
@@ -646,6 +646,11 @@ inline void dynamic::push_back(dynamic&& v) {
array.push_back(std::move(v));
}
+inline void dynamic::pop_back() {
+ auto& array = get<Array>();
+ array.pop_back();
+}
+
inline std::size_t dynamic::hash() const {
switch (type()) {
case OBJECT:
View
@@ -416,6 +416,14 @@ struct dynamic : private boost::operators<dynamic> {
void push_back(dynamic&&);
/*
+ * Remove an element from the back of an array. If this is not an array,
+ * throws TypeError.
+ *
+ * Does not invalidate iterators.
+ */
+ void pop_back();
+
+ /*
* Get a hash code. This function is called by a std::hash<>
* specialization, also.
*

0 comments on commit b9836f4

Please sign in to comment.