forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontainer_util.h
29 lines (22 loc) · 863 Bytes
/
container_util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2015 The Chromium Authors. All rights reserved.
// 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_
namespace cc {
// Removes the front element from the container and returns it.
template <typename Container>
typename Container::value_type PopFront(Container* container) {
typename Container::value_type element = std::move(container->front());
container->pop_front();
return element;
}
// Removes the back element from the container and returns it.
template <typename Container>
typename Container::value_type PopBack(Container* container) {
typename Container::value_type element = std::move(container->back());
container->pop_back();
return element;
}
} // namespace cc
#endif // CC_BASE_CONTAINER_UTIL_H_