Chromium Code Reviews| Index: cc/base/container_util.h |
| diff --git a/cc/base/container_util.h b/cc/base/container_util.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b57e4293a2378ccd1ec83c68c37de8c51eb6a35d |
| --- /dev/null |
| +++ b/cc/base/container_util.h |
| @@ -0,0 +1,28 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
|
danakj
2015/11/13 19:54:02
Can you move these to base/stl_util.h?
vmpstr
2015/11/13 23:15:38
I was under the impression that code should live c
danakj
2015/11/13 23:41:06
Crashpad will define new things in its own compat
vmpstr
2015/11/13 23:50:49
Ah OK. That makes sense.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CC_BASE_CONTAINER_UTIL_H_ |
| +#define CC_BASE_CONTAINER_UTIL_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| + |
| +namespace cc { |
| + |
| +template <typename Container> |
|
danakj
2015/11/13 19:54:02
please leave comments on these explaining what the
vmpstr
2015/11/13 23:15:38
Done.
|
| +typename Container::value_type TakeFront(Container* container) { |
| + typename Container::value_type element = std::move(container->front()); |
|
vmpstr
2015/11/12 08:56:01
Note that this is using std::move, to allow for no
danakj
2015/11/13 19:54:02
Ya, you should use .Pass() and a TODO if you want
vmpstr
2015/11/13 23:15:38
Done.
|
| + container->pop_front(); |
| + return element; |
| +} |
| + |
| +template <typename Container> |
| +typename Container::value_type TakeBack(Container* container) { |
| + typename Container::value_type element = std::move(container->back()); |
| + container->pop_back(); |
| + return element; |
| +} |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_BASE_CONTAINER_UTIL_H_ |