[core] Use mapbox::base::TypeWrapper instead of utils::peer
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/peer.hpp>
|
||||
#include <mbgl/util/immutable.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/style/conversion.hpp>
|
||||
|
||||
#include <mapbox/weak.hpp>
|
||||
#include <mapbox/type_wrapper.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
// For use in SDK bindings, which store a reference to a platform-native peer
|
||||
// object here, so that separately-obtained references to this object share
|
||||
// identical platform-native peers.
|
||||
util::peer peer;
|
||||
mapbox::base::TypeWrapper peer;
|
||||
Layer(Immutable<Impl>);
|
||||
|
||||
const LayerTypeInfo* getTypeInfo() const noexcept;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
#include <mbgl/util/peer.hpp>
|
||||
#include <mbgl/util/immutable.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
|
||||
#include <mapbox/weak.hpp>
|
||||
#include <mapbox/type_wrapper.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
// For use in SDK bindings, which store a reference to a platform-native peer
|
||||
// object here, so that separately-obtained references to this object share
|
||||
// identical platform-native peers.
|
||||
util::peer peer;
|
||||
mapbox::base::TypeWrapper peer;
|
||||
|
||||
virtual mapbox::base::WeakPtr<Source> makeWeakPtr() = 0;
|
||||
};
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
class peer {
|
||||
public:
|
||||
peer() noexcept : storage(nullptr, noop_deleter) {}
|
||||
|
||||
template <class T>
|
||||
peer(T&& value) noexcept : storage(new std::decay_t<T>(std::forward<T>(value)), cast_deleter<std::decay_t<T>>) {
|
||||
static_assert(!std::is_same<peer, std::decay_t<T>>::value, "Peer must not wrap itself.");
|
||||
}
|
||||
|
||||
bool has_value() const noexcept { return static_cast<bool>(storage); }
|
||||
|
||||
template <class T>
|
||||
T& get() noexcept { return *reinterpret_cast<T*>(storage.get()); }
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
static void cast_deleter(void* ptr) noexcept { delete reinterpret_cast<T*>(ptr); }
|
||||
static void noop_deleter(void*) noexcept {}
|
||||
|
||||
using storage_t = std::unique_ptr<void, void(*)(void*)>;
|
||||
storage_t storage;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace mbgl
|
||||
Reference in New Issue
Block a user