diff --git a/include/fit/implicit.hpp b/include/fit/implicit.hpp index 824cf18..e1df150 100644 --- a/include/fit/implicit.hpp +++ b/include/fit/implicit.hpp @@ -112,11 +112,12 @@ struct implicit { Pack p; - constexpr invoker(Pack pp) : p(pp) + constexpr invoker(Pack pp) FIT_NOEXCEPT_CONSTRUCTIBLE(Pack, Pack&&) + : p(fit::move(pp)) {} template, Pack, X>::value>::type> - constexpr operator X() const + constexpr operator X() const FIT_NOEXCEPT(noexcept(p(F()))) { return p(F()); } @@ -131,7 +132,7 @@ struct implicit }; template - static constexpr invoker make_invoker(Pack&& p) + static constexpr invoker make_invoker(Pack&& p) FIT_NOEXCEPT(noexcept(invoker(FIT_FORWARD(Pack)(p)))) { return invoker(FIT_FORWARD(Pack)(p)); } diff --git a/test/implicit.cpp b/test/implicit.cpp index 35e7ddd..3e16708 100644 --- a/test/implicit.cpp +++ b/test/implicit.cpp @@ -11,6 +11,16 @@ struct auto_caster } }; +template +struct auto_caster_noexcept +{ + template + T operator()(U x) noexcept + { + return T(x); + } +}; + struct auto_caster_foo { int i; @@ -30,3 +40,11 @@ FIT_TEST_CASE() FIT_TEST_CHECK(1 == x.i); } +#if FIT_HAS_NOEXCEPT_DEDUCTION +FIT_TEST_CASE() +{ + fit::implicit auto_cast{}; + float f = 1.5; + static_assert(noexcept(int(auto_cast(f))), "noexcept implicit"); +} +#endif