Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason
Conflicts: src/map/map.cpp
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "event.hpp"
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -58,7 +60,7 @@ public:
|
||||
|
||||
template<typename T, typename ...Args>
|
||||
static inline const T &Set(Args&& ...args) {
|
||||
Backend = ::std::unique_ptr<T>(new T(::std::forward<Args>(args)...));
|
||||
Backend = util::make_unique<T>(::std::forward<Args>(args)...);
|
||||
return *dynamic_cast<T *>(Backend.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,20 +2,35 @@
|
||||
#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)...));
|
||||
}
|
||||
|
||||
}
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
// C++14 backfill based on http://llvm.org/svn/llvm-project/libcxx/trunk/include/memory
|
||||
|
||||
namespace detail {
|
||||
template<class T> struct unique_type { typedef ::std::unique_ptr<T> single; };
|
||||
template<class T> struct unique_type<T[]> { typedef ::std::unique_ptr<T[]> unknown_bound; };
|
||||
template<class T, size_t size> struct unique_type<T[size]> { typedef void known_bound; };
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
typename detail::unique_type<T>::single make_unique(Args&&... args) {
|
||||
return ::std::unique_ptr<T>(new T(::std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
typename detail::unique_type<T>::unknown_bound make_unique(size_t size) {
|
||||
return ::std::unique_ptr<T>(new typename ::std::remove_extent<T>::type[size]());
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
typename detail::unique_type<T>::known_bound make_unique(Args&&...) = delete;
|
||||
|
||||
|
||||
|
||||
template <typename Container, typename ForwardIterator, typename Predicate>
|
||||
void erase_if(Container &container, ForwardIterator it, const ForwardIterator end, Predicate pred) {
|
||||
while (it != end) {
|
||||
|
||||
Reference in New Issue
Block a user