summaryrefslogtreecommitdiff
path: root/include/mbgl/util/variant.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-10-22 16:29:10 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-10-22 16:29:10 +0200
commit7d6feffd56cde7d6e5d9dd53b358f5afa8e4eb47 (patch)
treebf152444305b89c25d73028cac813875c9e312bc /include/mbgl/util/variant.hpp
parent2422e938ac87f5790c4977d93e667c95e695f76c (diff)
downloadqtlocation-mapboxgl-7d6feffd56cde7d6e5d9dd53b358f5afa8e4eb47.tar.gz
replace boost optional with mapbox optional
Diffstat (limited to 'include/mbgl/util/variant.hpp')
-rw-r--r--include/mbgl/util/variant.hpp20
1 files changed, 5 insertions, 15 deletions
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 <utility>
#include <typeinfo>
#include <type_traits>
-#include <algorithm> // std::move/swap
#include <stdexcept> // runtime_error
#include <new> // operator new
#include <cstddef> // 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 <typename T, class = typename std::enable_if<
- detail::is_valid_type<T, Types...>::value>::type>
- VARIANT_INLINE explicit variant(T const& val) noexcept
- : type_index(detail::value_traits<T, Types...>::index)
- {
- constexpr std::size_t index = sizeof...(Types) - detail::value_traits<T, Types...>::index - 1;
- using target_type = typename detail::select_type<index, Types...>::type;
- new (&data) target_type(val);
- }
-
- template <typename T, class = typename std::enable_if<
- detail::is_valid_type<T, Types...>::value>::type>
+ detail::is_valid_type<typename std::remove_reference<T>::type, Types...>::value>::type>
VARIANT_INLINE variant(T && val) noexcept
- : type_index(detail::value_traits<T, Types...>::index)
+ : type_index(detail::value_traits<typename std::remove_reference<T>::type, Types...>::index)
{
- constexpr std::size_t index = sizeof...(Types) - detail::value_traits<T, Types...>::index - 1;
+ constexpr std::size_t index = sizeof...(Types) - detail::value_traits<typename std::remove_reference<T>::type, Types...>::index - 1;
using target_type = typename detail::select_type<index, Types...>::type;
new (&data) target_type(std::forward<T>(val)); // nothrow
}
@@ -565,7 +555,7 @@ public:
template <typename T>
VARIANT_INLINE variant<Types...>& operator=(T && rhs) noexcept
{
- variant<Types...> temp(std::move(rhs));
+ variant<Types...> temp(std::forward<T>(rhs));
swap(*this, temp);
return *this;
}