From 0985cc907dc748f484c3e44ca1f2cdf3bbf41d5e Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 4 Sep 2014 14:54:42 +0100 Subject: [PATCH] remove copy converting ctor and fix converting move constuctor to use 'universal reference' and perfect forwarding ( re : http://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers) --- include/mapnik/util/variant.hpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/include/mapnik/util/variant.hpp b/include/mapnik/util/variant.hpp index d6f800251..88a81f5b5 100644 --- a/include/mapnik/util/variant.hpp +++ b/include/mapnik/util/variant.hpp @@ -541,21 +541,11 @@ public: : type_index(detail::invalid_value) {} 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 }