diff options
Diffstat (limited to 'include/mbgl')
-rw-r--r-- | include/mbgl/style/layer.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/style/source.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/util/peer.hpp | 34 |
3 files changed, 4 insertions, 38 deletions
diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp index cfaca60e60..ecd3f01f70 100644 --- a/include/mbgl/style/layer.hpp +++ b/include/mbgl/style/layer.hpp @@ -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; diff --git a/include/mbgl/style/source.hpp b/include/mbgl/style/source.hpp index 1d5223fa0d..2507b67fdc 100644 --- a/include/mbgl/style/source.hpp +++ b/include/mbgl/style/source.hpp @@ -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; }; diff --git a/include/mbgl/util/peer.hpp b/include/mbgl/util/peer.hpp deleted file mode 100644 index d16efddb57..0000000000 --- a/include/mbgl/util/peer.hpp +++ /dev/null @@ -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 |