From 7d6feffd56cde7d6e5d9dd53b358f5afa8e4eb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 16:29:10 +0200 Subject: replace boost optional with mapbox optional --- include/mbgl/util/variant.hpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'include/mbgl/util/variant.hpp') diff --git a/include/mbgl/util/variant.hpp b/include/mbgl/util/variant.hpp index 1eca5160c7..3b5659425a 100644 --- a/include/mbgl/util/variant.hpp +++ b/include/mbgl/util/variant.hpp @@ -4,7 +4,6 @@ #include #include #include -#include // std::move/swap #include // runtime_error #include // operator new #include // size_t @@ -515,22 +514,13 @@ public: VARIANT_INLINE variant(no_init) : type_index(detail::invalid_value) {} + // http://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers template ::value>::type> - VARIANT_INLINE explicit variant(T const& val) noexcept - : type_index(detail::value_traits::index) - { - constexpr std::size_t index = sizeof...(Types) - detail::value_traits::index - 1; - using target_type = typename detail::select_type::type; - new (&data) target_type(val); - } - - template ::value>::type> + detail::is_valid_type::type, Types...>::value>::type> VARIANT_INLINE variant(T && val) noexcept - : type_index(detail::value_traits::index) + : type_index(detail::value_traits::type, Types...>::index) { - constexpr std::size_t index = sizeof...(Types) - detail::value_traits::index - 1; + constexpr std::size_t index = sizeof...(Types) - detail::value_traits::type, Types...>::index - 1; using target_type = typename detail::select_type::type; new (&data) target_type(std::forward(val)); // nothrow } @@ -565,7 +555,7 @@ public: template VARIANT_INLINE variant& operator=(T && rhs) noexcept { - variant temp(std::move(rhs)); + variant temp(std::forward(rhs)); swap(*this, temp); return *this; } -- cgit v1.2.1