diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-07-16 18:53:56 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-07-16 18:53:56 -0700 |
commit | 4ea281c750c5afcc68f2832bb42d98a1cbce6735 (patch) | |
tree | 60bc7d3ccba2c54859e2e023997cc027cc67aea7 /include/mbgl/util/std.hpp | |
parent | c1a64dc5fa73b54cc5de77629781dfc74302a1e7 (diff) | |
download | qtlocation-mapboxgl-4ea281c750c5afcc68f2832bb42d98a1cbce6735.tar.gz |
rename llmr => mbgl
Diffstat (limited to 'include/mbgl/util/std.hpp')
-rw-r--r-- | include/mbgl/util/std.hpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/mbgl/util/std.hpp b/include/mbgl/util/std.hpp new file mode 100644 index 0000000000..051f89bb60 --- /dev/null +++ b/include/mbgl/util/std.hpp @@ -0,0 +1,38 @@ +#ifndef MBGL_UTIL_STD +#define MBGL_UTIL_STD + +#include <memory> + +namespace std { + +// C++14 backfill from http://herbsutter.com/gotw/_102/ +template<typename T, typename ...Args> +::std::unique_ptr<T> make_unique(Args&& ...args) { + return ::std::unique_ptr<T>(new T(::std::forward<Args>(args)...)); +} + +} + +namespace mbgl { +namespace util { + +template <typename Container, typename ForwardIterator, typename Predicate> +void erase_if(Container &container, ForwardIterator it, const ForwardIterator end, Predicate pred) { + while (it != end) { + if (pred(*it)) { + container.erase(it++); + } else { + ++it; + } + } +} + +template <typename Container, typename Predicate> +void erase_if(Container &container, Predicate pred) { + erase_if(container, container.begin(), container.end(), pred); +} + +} +} + +#endif |