diff -Nru mapbox-variant-1.1.6/CHANGELOG.md mapbox-variant-1.2.0/CHANGELOG.md --- mapbox-variant-1.1.6/CHANGELOG.md 2019-04-25 14:09:06.000000000 +0000 +++ mapbox-variant-1.2.0/CHANGELOG.md 2020-08-03 14:07:09.000000000 +0000 @@ -1,5 +1,17 @@ # Variant changelog +## 1.2.0 + +Released: July 3, 2020 + +(82f9561) + +* Use perfect forwarding for internal value types deductions (#178) (#180) +* Implement support for "moving" values out (#142) (#178) (#180) +* Preserve ability to specify explicit `return_type` in visitors (#181) +* Add self-assignment checks in copy and move assignment operator= (#164) +* Add relevant tests + ## 1.1.6 Released: April 25, 2019 diff -Nru mapbox-variant-1.1.6/debian/changelog mapbox-variant-1.2.0/debian/changelog --- mapbox-variant-1.1.6/debian/changelog 2019-07-07 06:35:09.000000000 +0000 +++ mapbox-variant-1.2.0/debian/changelog 2020-08-03 14:55:41.000000000 +0000 @@ -1,3 +1,17 @@ +mapbox-variant (1.2.0-1) unstable; urgency=medium + + [ Bas Couwenberg ] + * New upstream release. + * Bump Standards-Version to 4.5.0, no changes. + * Drop Name field from upstream metadata. + * Bump debhelper compat to 10, changes: + - Drop --parallel option, enabled by default + + [ Helmut Grohne ] + * Mark libmapbox-variant-dev Multi-Arch: foreign. (Closes: #940618) + + -- Bas Couwenberg Mon, 03 Aug 2020 16:55:41 +0200 + mapbox-variant (1.1.6-1) unstable; urgency=medium * Update gbp.conf to use --source-only-changes by default. diff -Nru mapbox-variant-1.1.6/debian/compat mapbox-variant-1.2.0/debian/compat --- mapbox-variant-1.1.6/debian/compat 2016-02-26 20:34:48.000000000 +0000 +++ mapbox-variant-1.2.0/debian/compat 2020-03-19 18:12:04.000000000 +0000 @@ -1 +1 @@ -9 +10 diff -Nru mapbox-variant-1.1.6/debian/control mapbox-variant-1.2.0/debian/control --- mapbox-variant-1.1.6/debian/control 2018-12-25 21:33:55.000000000 +0000 +++ mapbox-variant-1.2.0/debian/control 2020-03-19 18:12:11.000000000 +0000 @@ -3,18 +3,19 @@ Priority: optional Maintainer: Debian GIS Project Uploaders: Bas Couwenberg -Build-Depends: debhelper (>= 9), +Build-Depends: debhelper (>= 10~), libboost-dev, libboost-system-dev, libboost-timer-dev, libboost-chrono-dev -Standards-Version: 4.3.0 +Standards-Version: 4.5.0 Vcs-Browser: https://salsa.debian.org/debian-gis-team/mapbox-variant/ Vcs-Git: https://salsa.debian.org/debian-gis-team/mapbox-variant.git Homepage: https://github.com/mapbox/variant Package: libmapbox-variant-dev Architecture: all +Multi-Arch: foreign Depends: ${misc:Depends} Description: Alternative to boost::variant for C++11 Mapbox variant has the same speedy performance of boost::variant but is diff -Nru mapbox-variant-1.1.6/debian/rules mapbox-variant-1.2.0/debian/rules --- mapbox-variant-1.1.6/debian/rules 2018-05-07 19:06:01.000000000 +0000 +++ mapbox-variant-1.2.0/debian/rules 2020-03-19 18:12:16.000000000 +0000 @@ -3,4 +3,4 @@ # DH_VERBOSE := 1 %: - dh $@ --parallel + dh $@ diff -Nru mapbox-variant-1.1.6/debian/upstream/metadata mapbox-variant-1.2.0/debian/upstream/metadata --- mapbox-variant-1.1.6/debian/upstream/metadata 2016-02-26 20:50:20.000000000 +0000 +++ mapbox-variant-1.2.0/debian/upstream/metadata 2019-12-09 08:16:19.000000000 +0000 @@ -1,6 +1,5 @@ --- Bug-Database: https://github.com/mapbox/variant/issues Bug-Submit: https://github.com/mapbox/variant/issues/new -Name: Mapbox variant Repository: https://github.com/mapbox/variant.git Repository-Browse: https://github.com/mapbox/variant diff -Nru mapbox-variant-1.1.6/include/mapbox/variant.hpp mapbox-variant-1.2.0/include/mapbox/variant.hpp --- mapbox-variant-1.1.6/include/mapbox/variant.hpp 2019-04-25 14:09:06.000000000 +0000 +++ mapbox-variant-1.2.0/include/mapbox/variant.hpp 2020-08-03 14:07:09.000000000 +0000 @@ -171,36 +171,57 @@ using target_type = typename std::tuple_element>::type; }; -template -struct enable_if_type +template +struct copy_cvref { - using type = R; + using type = Dest; }; -template -struct result_of_unary_visit +template +struct copy_cvref { - using type = typename std::result_of::type; + using type = Dest const&; }; -template -struct result_of_unary_visit::type> +template +struct copy_cvref { - using type = typename F::result_type; + using type = Dest&; }; -template -struct result_of_binary_visit +template +struct copy_cvref { - using type = typename std::result_of::type; + using type = Dest&&; }; -template -struct result_of_binary_visit::type> +template +struct deduced_result_type +{}; + +template +struct deduced_result_type()(std::declval()...))> +{ + using type = decltype(std::declval()(std::declval()...)); +}; + +template +struct visitor_result_type : deduced_result_type +{}; + +// specialization for explicit result_type member in visitor class +template +struct visitor_result_type::type::result_type>())> { - using type = typename F::result_type; + using type = typename std::decay::type::result_type; }; +template +using result_of_unary_visit = typename visitor_result_type::type; + +template +using result_of_binary_visit = typename visitor_result_type::type; + template struct static_max; @@ -270,245 +291,174 @@ template struct unwrapper { - static T const& apply_const(T const& obj) { return obj; } - static T& apply(T& obj) { return obj; } -}; + using value_type = T; -template -struct unwrapper> -{ - static auto apply_const(recursive_wrapper const& obj) - -> typename recursive_wrapper::type const& + template + static auto apply(typename std::remove_reference::type& var) + -> typename std::enable_if::value, + decltype(var.template get_unchecked())>::type { - return obj.get(); + return var.template get_unchecked(); } - static auto apply(recursive_wrapper& obj) - -> typename recursive_wrapper::type& + + template + static auto apply(typename std::remove_reference::type& var) + -> typename std::enable_if::value, + decltype(std::move(var.template get_unchecked()))>::type { - return obj.get(); + return std::move(var.template get_unchecked()); } }; template -struct unwrapper> -{ - static auto apply_const(std::reference_wrapper const& obj) - -> typename std::reference_wrapper::type const& - { - return obj.get(); - } - static auto apply(std::reference_wrapper& obj) - -> typename std::reference_wrapper::type& - { - return obj.get(); - } -}; +struct unwrapper> : unwrapper +{}; + +template +struct unwrapper> : unwrapper +{}; -template +template struct dispatcher; -template -struct dispatcher +template +struct dispatcher { - VARIANT_INLINE static R apply_const(V const& v, F&& f) - { - if (v.template is()) - { - return f(unwrapper::apply_const(v.template get_unchecked())); - } - else - { - return dispatcher::apply_const(v, std::forward(f)); - } - } - - VARIANT_INLINE static R apply(V& v, F&& f) + template + VARIANT_INLINE static R apply(V&& v, F&& f) { if (v.template is()) { - return f(unwrapper::apply(v.template get_unchecked())); + return std::forward(f)(unwrapper::template apply(v)); } else { - return dispatcher::apply(v, std::forward(f)); + return dispatcher::apply(std::forward(v), std::forward(f)); } } }; -template -struct dispatcher +template +struct dispatcher { - VARIANT_INLINE static R apply_const(V const& v, F&& f) + template + VARIANT_INLINE static R apply(V&& v, F&& f) { - return f(unwrapper::apply_const(v.template get_unchecked())); - } - - VARIANT_INLINE static R apply(V& v, F&& f) - { - return f(unwrapper::apply(v.template get_unchecked())); + return std::forward(f)(unwrapper::template apply(v)); } }; -template +template struct binary_dispatcher_rhs; -template -struct binary_dispatcher_rhs +template +struct binary_dispatcher_rhs { - VARIANT_INLINE static R apply_const(V const& lhs, V const& rhs, F&& f) - { - if (rhs.template is()) // call binary functor - { - return f(unwrapper::apply_const(lhs.template get_unchecked()), - unwrapper::apply_const(rhs.template get_unchecked())); - } - else - { - return binary_dispatcher_rhs::apply_const(lhs, rhs, std::forward(f)); - } - } - - VARIANT_INLINE static R apply(V& lhs, V& rhs, F&& f) + template + VARIANT_INLINE static R apply(V&& lhs, V&& rhs, F&& f) { if (rhs.template is()) // call binary functor { - return f(unwrapper::apply(lhs.template get_unchecked()), - unwrapper::apply(rhs.template get_unchecked())); + return std::forward(f)(unwrapper::template apply(lhs), + unwrapper::template apply(rhs)); } else { - return binary_dispatcher_rhs::apply(lhs, rhs, std::forward(f)); + return binary_dispatcher_rhs::apply(std::forward(lhs), + std::forward(rhs), + std::forward(f)); } } }; -template -struct binary_dispatcher_rhs +template +struct binary_dispatcher_rhs { - VARIANT_INLINE static R apply_const(V const& lhs, V const& rhs, F&& f) + template + VARIANT_INLINE static R apply(V&& lhs, V&& rhs, F&& f) { - return f(unwrapper::apply_const(lhs.template get_unchecked()), - unwrapper::apply_const(rhs.template get_unchecked())); - } - - VARIANT_INLINE static R apply(V& lhs, V& rhs, F&& f) - { - return f(unwrapper::apply(lhs.template get_unchecked()), - unwrapper::apply(rhs.template get_unchecked())); + return std::forward(f)(unwrapper::template apply(lhs), + unwrapper::template apply(rhs)); } }; -template +template struct binary_dispatcher_lhs; -template -struct binary_dispatcher_lhs +template +struct binary_dispatcher_lhs { - VARIANT_INLINE static R apply_const(V const& lhs, V const& rhs, F&& f) - { - if (lhs.template is()) // call binary functor - { - return f(unwrapper::apply_const(lhs.template get_unchecked()), - unwrapper::apply_const(rhs.template get_unchecked())); - } - else - { - return binary_dispatcher_lhs::apply_const(lhs, rhs, std::forward(f)); - } - } - - VARIANT_INLINE static R apply(V& lhs, V& rhs, F&& f) + template + VARIANT_INLINE static R apply(V&& lhs, V&& rhs, F&& f) { if (lhs.template is()) // call binary functor { - return f(unwrapper::apply(lhs.template get_unchecked()), - unwrapper::apply(rhs.template get_unchecked())); + return std::forward(f)(unwrapper::template apply(lhs), + unwrapper::template apply(rhs)); } else { - return binary_dispatcher_lhs::apply(lhs, rhs, std::forward(f)); + return binary_dispatcher_lhs::apply(std::forward(lhs), + std::forward(rhs), + std::forward(f)); } } }; -template -struct binary_dispatcher_lhs +template +struct binary_dispatcher_lhs { - VARIANT_INLINE static R apply_const(V const& lhs, V const& rhs, F&& f) + template + VARIANT_INLINE static R apply(V&& lhs, V&& rhs, F&& f) { - return f(unwrapper::apply_const(lhs.template get_unchecked()), - unwrapper::apply_const(rhs.template get_unchecked())); - } - - VARIANT_INLINE static R apply(V& lhs, V& rhs, F&& f) - { - return f(unwrapper::apply(lhs.template get_unchecked()), - unwrapper::apply(rhs.template get_unchecked())); + return std::forward(f)(unwrapper::template apply(lhs), + unwrapper::template apply(rhs)); } }; -template +template struct binary_dispatcher; -template -struct binary_dispatcher +template +struct binary_dispatcher { - VARIANT_INLINE static R apply_const(V const& v0, V const& v1, F&& f) - { - if (v0.template is()) - { - if (v1.template is()) - { - return f(unwrapper::apply_const(v0.template get_unchecked()), - unwrapper::apply_const(v1.template get_unchecked())); // call binary functor - } - else - { - return binary_dispatcher_rhs::apply_const(v0, v1, std::forward(f)); - } - } - else if (v1.template is()) - { - return binary_dispatcher_lhs::apply_const(v0, v1, std::forward(f)); - } - return binary_dispatcher::apply_const(v0, v1, std::forward(f)); - } - - VARIANT_INLINE static R apply(V& v0, V& v1, F&& f) + template + VARIANT_INLINE static R apply(V&& v0, V&& v1, F&& f) { if (v0.template is()) { if (v1.template is()) { - return f(unwrapper::apply(v0.template get_unchecked()), - unwrapper::apply(v1.template get_unchecked())); // call binary functor + return std::forward(f)(unwrapper::template apply(v0), + unwrapper::template apply(v1)); // call binary functor } else { - return binary_dispatcher_rhs::apply(v0, v1, std::forward(f)); + return binary_dispatcher_rhs::apply(std::forward(v0), + std::forward(v1), + std::forward(f)); } } else if (v1.template is()) { - return binary_dispatcher_lhs::apply(v0, v1, std::forward(f)); + return binary_dispatcher_lhs::apply(std::forward(v0), + std::forward(v1), + std::forward(f)); } - return binary_dispatcher::apply(v0, v1, std::forward(f)); + return binary_dispatcher::apply(std::forward(v0), + std::forward(v1), + std::forward(f)); } }; -template -struct binary_dispatcher +template +struct binary_dispatcher { - VARIANT_INLINE static R apply_const(V const& v0, V const& v1, F&& f) + template + VARIANT_INLINE static R apply(V&& v0, V&& v1, F&& f) { - return f(unwrapper::apply_const(v0.template get_unchecked()), - unwrapper::apply_const(v1.template get_unchecked())); // call binary functor - } - - VARIANT_INLINE static R apply(V& v0, V& v1, F&& f) - { - return f(unwrapper::apply(v0.template get_unchecked()), - unwrapper::apply(v1.template get_unchecked())); // call binary functor + return std::forward(f)(unwrapper::template apply(v0), + unwrapper::template apply(v1)); // call binary functor } }; @@ -579,16 +529,20 @@ using types = std::tuple; private: using first_type = typename std::tuple_element<0, types>::type; + using unwrap_first_type = typename detail::unwrapper::value_type; using data_type = typename std::aligned_storage::type; using helper_type = detail::variant_helper; + template + using alternative_ref = typename detail::copy_cvref::type; + type_index_t type_index; #ifdef __clang_analyzer__ data_type data {}; #else data_type data; #endif - + public: VARIANT_INLINE variant() noexcept(std::is_nothrow_default_constructible::value) : type_index(sizeof...(Types)-1) @@ -645,13 +599,18 @@ // move_assign uses move-construction via placement new. noexcept(detail::conjunction...>::value) { + if (this == &other) { // playing safe in release mode, hit assertion in debug. + assert(false); + return *this; + } move_assign(std::move(other)); return *this; } VARIANT_INLINE variant& operator=(variant const& other) { - copy_assign(other); + if (this != &other) + copy_assign(other); return *this; } @@ -872,51 +831,44 @@ // visitor // unary - template ::type> - auto VARIANT_INLINE static visit(V const& v, F&& f) - -> decltype(detail::dispatcher::apply_const(v, std::forward(f))) + template , + typename R = detail::result_of_unary_visit> + VARIANT_INLINE static R visit(V&& v, F&& f) { - return detail::dispatcher::apply_const(v, std::forward(f)); - } - // non-const - template ::type> - auto VARIANT_INLINE static visit(V& v, F&& f) - -> decltype(detail::dispatcher::apply(v, std::forward(f))) - { - return detail::dispatcher::apply(v, std::forward(f)); + return detail::dispatcher::apply(std::forward(v), std::forward(f)); } // binary - // const - template ::type> - auto VARIANT_INLINE static binary_visit(V const& v0, V const& v1, F&& f) - -> decltype(detail::binary_dispatcher::apply_const(v0, v1, std::forward(f))) - { - return detail::binary_dispatcher::apply_const(v0, v1, std::forward(f)); - } - // non-const - template ::type> - auto VARIANT_INLINE static binary_visit(V& v0, V& v1, F&& f) - -> decltype(detail::binary_dispatcher::apply(v0, v1, std::forward(f))) - { - return detail::binary_dispatcher::apply(v0, v1, std::forward(f)); + template , + typename R = detail::result_of_binary_visit> + VARIANT_INLINE static R binary_visit(V&& v0, V&& v1, F&& f) + { + return detail::binary_dispatcher::apply(std::forward(v0), + std::forward(v1), + std::forward(f)); } // match // unary template - auto VARIANT_INLINE match(Fs&&... fs) const + auto VARIANT_INLINE match(Fs&&... fs) const& -> decltype(variant::visit(*this, ::mapbox::util::make_visitor(std::forward(fs)...))) { return variant::visit(*this, ::mapbox::util::make_visitor(std::forward(fs)...)); } // non-const template - auto VARIANT_INLINE match(Fs&&... fs) + auto VARIANT_INLINE match(Fs&&... fs) & -> decltype(variant::visit(*this, ::mapbox::util::make_visitor(std::forward(fs)...))) { return variant::visit(*this, ::mapbox::util::make_visitor(std::forward(fs)...)); } + template + auto VARIANT_INLINE match(Fs&&... fs) && + -> decltype(variant::visit(std::move(*this), ::mapbox::util::make_visitor(std::forward(fs)...))) + { + return variant::visit(std::move(*this), ::mapbox::util::make_visitor(std::forward(fs)...)); + } ~variant() noexcept // no-throw destructor { @@ -967,33 +919,19 @@ }; // unary visitor interface -// const -template -auto VARIANT_INLINE apply_visitor(F&& f, V const& v) -> decltype(V::visit(v, std::forward(f))) -{ - return V::visit(v, std::forward(f)); -} - -// non-const template -auto VARIANT_INLINE apply_visitor(F&& f, V& v) -> decltype(V::visit(v, std::forward(f))) +auto VARIANT_INLINE apply_visitor(F&& f, V&& v) + -> decltype(v.visit(std::forward(v), std::forward(f))) { - return V::visit(v, std::forward(f)); + return v.visit(std::forward(v), std::forward(f)); } // binary visitor interface -// const -template -auto VARIANT_INLINE apply_visitor(F&& f, V const& v0, V const& v1) -> decltype(V::binary_visit(v0, v1, std::forward(f))) -{ - return V::binary_visit(v0, v1, std::forward(f)); -} - -// non-const template -auto VARIANT_INLINE apply_visitor(F&& f, V& v0, V& v1) -> decltype(V::binary_visit(v0, v1, std::forward(f))) +auto VARIANT_INLINE apply_visitor(F&& f, V&& v0, V&& v1) + -> decltype(v0.binary_visit(std::forward(v0), std::forward(v1), std::forward(f))) { - return V::binary_visit(v0, v1, std::forward(f)); + return v0.binary_visit(std::forward(v0), std::forward(v1), std::forward(f)); } // getter interface diff -Nru mapbox-variant-1.1.6/Makefile mapbox-variant-1.2.0/Makefile --- mapbox-variant-1.1.6/Makefile 2019-04-25 14:09:06.000000000 +0000 +++ mapbox-variant-1.2.0/Makefile 2020-08-03 14:07:09.000000000 +0000 @@ -99,7 +99,25 @@ mkdir -p ./out $(CXX) -c -o $@ $< -Iinclude -isystem test/include $(FINAL_CXXFLAGS) -out/unit: out/unit.o out/binary_visitor_1.o out/binary_visitor_2.o out/binary_visitor_3.o out/binary_visitor_4.o out/binary_visitor_5.o out/binary_visitor_6.o out/issue21.o out/issue122.o out/mutating_visitor.o out/optional.o out/recursive_wrapper.o out/sizeof.o out/unary_visitor.o out/variant.o out/variant_alternative.o out/nothrow_move.o +out/unit: out/unit.o \ + out/binary_visitor_1.o \ + out/binary_visitor_2.o \ + out/binary_visitor_3.o \ + out/binary_visitor_4.o \ + out/binary_visitor_5.o \ + out/binary_visitor_6.o \ + out/issue21.o \ + out/issue122.o \ + out/mutating_visitor.o \ + out/optional.o \ + out/recursive_wrapper.o \ + out/sizeof.o \ + out/unary_visitor.o \ + out/variant.o \ + out/variant_alternative.o \ + out/nothrow_move.o \ + out/visitor_result_type.o \ + mkdir -p ./out $(CXX) -o $@ $^ $(LDFLAGS) diff -Nru mapbox-variant-1.1.6/test/compilation_failure/get_type.cpp mapbox-variant-1.2.0/test/compilation_failure/get_type.cpp --- mapbox-variant-1.1.6/test/compilation_failure/get_type.cpp 2019-04-25 14:09:06.000000000 +0000 +++ mapbox-variant-1.2.0/test/compilation_failure/get_type.cpp 2020-08-03 14:07:09.000000000 +0000 @@ -1,4 +1,4 @@ -// @EXPECTED: enable_if +// @EXPECTED: no matching .*\ #include diff -Nru mapbox-variant-1.1.6/test/compilation_failure/mutating_visitor_on_const.cpp mapbox-variant-1.2.0/test/compilation_failure/mutating_visitor_on_const.cpp --- mapbox-variant-1.1.6/test/compilation_failure/mutating_visitor_on_const.cpp 2019-04-25 14:09:06.000000000 +0000 +++ mapbox-variant-1.2.0/test/compilation_failure/mutating_visitor_on_const.cpp 2020-08-03 14:07:09.000000000 +0000 @@ -1,4 +1,4 @@ -// @EXPECTED: const int +// @EXPECTED: no matching function for call to .*\ #include diff -Nru mapbox-variant-1.1.6/test/lambda_overload_test.cpp mapbox-variant-1.2.0/test/lambda_overload_test.cpp --- mapbox-variant-1.1.6/test/lambda_overload_test.cpp 2019-04-25 14:09:06.000000000 +0000 +++ mapbox-variant-1.2.0/test/lambda_overload_test.cpp 2020-08-03 14:07:09.000000000 +0000 @@ -10,6 +10,15 @@ using namespace mapbox::util; +template +struct tag +{ + static void dump(const char* prefix) + { + std::cout << prefix << ": " << typeid(tag).name() << std::endl; + } +}; + template using Either = mapbox::util::variant; @@ -55,6 +64,37 @@ apply_visitor(make_visitor([](int) {}), singleton); } +// See #180 +struct test_call_nonconst_member_visitor +{ + template + void operator() (T & obj) const + { + tag::dump("test_call_nonconst_member: visitor"); + obj.foo(); + } +}; + +void test_call_nonconst_member() +{ + struct object + { + void foo() { val = 42;} + int val = 0; + }; + + variant v = object{}; + apply_visitor(test_call_nonconst_member_visitor{}, v); + +#ifdef HAS_CPP14_SUPPORT + apply_visitor([](auto& obj) + { + tag::dump("test_call_nonconst_member: lambda"); + obj.foo(); + }, v); +#endif +} + void test_lambda_overloads_sfinae() #ifdef HAS_CPP14_SUPPORT { @@ -193,10 +233,41 @@ } #endif +template +struct Moveable +{ + Moveable() = default; // Default constructible + + Moveable(const Moveable&) = delete; // Disable copy ctor + Moveable& operator=(const Moveable&) = delete; // Disable copy assign op + + Moveable(Moveable&&) = default; // Enable move ctor + Moveable& operator=(Moveable&&) = default; // Enable move assign op +}; + +void test_match_move_out_of_variant() +{ + // Distinguishable at type level + using T1 = Moveable; + using T2 = Moveable; + using T3 = mapbox::util::recursive_wrapper; + + mapbox::util::variant v = T1{}; + + std::move(v).match([](T1&&) {}, // Consume T1 by value + [](T2&&) {}); // Consume T2 by value + + mapbox::util::variant w = T2{}; + + std::move(w).match([](int&&) {}, // Consume unwrapped int + [](T2&&) {}); // Consume T2 by value +} + int main() { test_lambda_overloads(); test_singleton_variant(); + test_call_nonconst_member(); test_lambda_overloads_capture(); test_lambda_overloads_sfinae(); @@ -205,6 +276,7 @@ test_match_overloads_capture(); test_match_overloads_init_capture(); test_match_overloads_otherwise(); + test_match_move_out_of_variant(); } #undef HAS_CPP14_SUPPORT diff -Nru mapbox-variant-1.1.6/test/t/optional.cpp mapbox-variant-1.2.0/test/t/optional.cpp --- mapbox-variant-1.1.6/test/t/optional.cpp 2019-04-25 14:09:06.000000000 +0000 +++ mapbox-variant-1.2.0/test/t/optional.cpp 2020-08-03 14:07:09.000000000 +0000 @@ -1,4 +1,3 @@ - #include "catch.hpp" #include @@ -97,6 +96,8 @@ a = 1; REQUIRE(a.get() == 1); +#if !defined(__clang__) a = a; REQUIRE(a.get() == 1); +#endif } diff -Nru mapbox-variant-1.1.6/test/t/visitor_result_type.cpp mapbox-variant-1.2.0/test/t/visitor_result_type.cpp --- mapbox-variant-1.1.6/test/t/visitor_result_type.cpp 1970-01-01 00:00:00.000000000 +0000 +++ mapbox-variant-1.2.0/test/t/visitor_result_type.cpp 2020-08-03 14:07:09.000000000 +0000 @@ -0,0 +1,52 @@ +#include + +using namespace mapbox::util; + +namespace { + +template +struct tag {}; + +struct deduced_result_visitor +{ + template + tag operator() (T); + + template + tag operator() (T) const; + + template + tag operator() (T, U); + + template + tag operator() (T, U) const; +}; + +struct explicit_result_visitor : deduced_result_visitor +{ + using result_type = tag; +}; + +// Doing this compile-time test via assignment to typed tag objects gives +// more useful error messages when something goes wrong, than std::is_same +// in a static_assert would. Here if result_of_unary_visit returns anything +// other than the expected type on the left hand side, the conversion error +// message will tell you exactly what it was. + +#ifdef __clang__ +# pragma clang diagnostic ignored "-Wunused-variable" +#endif + +tag d1m = detail::result_of_unary_visit{}; +tag d1c = detail::result_of_unary_visit{}; + +tag e1m = detail::result_of_unary_visit{}; +tag e1c = detail::result_of_unary_visit{}; + +tag d2m = detail::result_of_binary_visit{}; +tag d2c = detail::result_of_binary_visit{}; + +tag e2m = detail::result_of_binary_visit{}; +tag e2c = detail::result_of_binary_visit{}; + +} // namespace diff -Nru mapbox-variant-1.1.6/.travis.yml mapbox-variant-1.2.0/.travis.yml --- mapbox-variant-1.1.6/.travis.yml 2019-04-25 14:09:06.000000000 +0000 +++ mapbox-variant-1.2.0/.travis.yml 2020-08-03 14:07:09.000000000 +0000 @@ -90,20 +90,6 @@ sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6' ] packages: [ 'clang-3.6' ] - os: linux - compiler: "clang37" - env: CXX=clang++-3.7 - addons: - apt: - sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7' ] - packages: [ 'clang-3.7' ] - - os: linux - compiler: "gcc47" - env: CXX=g++-4.7 CXXFLAGS="-Wno-parentheses" - addons: - apt: - sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'g++-4.7' ] - - os: linux compiler: "gcc48" env: CXX=g++-4.8 addons: @@ -145,6 +131,7 @@ script: # Build in Release + - make - make test - make bench - make sizes @@ -152,6 +139,7 @@ - make clean; # Build in Debug - export BUILDTYPE=Debug + - make - make test - make bench - make sizes