2
0
mirror of https://github.com/boostorg/hof.git synced 2026-01-19 16:22:17 +00:00

Add noexcept support for implicit

This commit is contained in:
Paul
2017-01-04 17:29:37 -06:00
parent 6fa2cf0e57
commit dadf8cbcd3
2 changed files with 22 additions and 3 deletions

View File

@@ -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<class X, class=typename std::enable_if<detail::is_implicit_callable<F<X>, Pack, X>::value>::type>
constexpr operator X() const
constexpr operator X() const FIT_NOEXCEPT(noexcept(p(F<X>())))
{
return p(F<X>());
}
@@ -131,7 +132,7 @@ struct implicit
};
template<class Pack>
static constexpr invoker<Pack> make_invoker(Pack&& p)
static constexpr invoker<Pack> make_invoker(Pack&& p) FIT_NOEXCEPT(noexcept(invoker<Pack>(FIT_FORWARD(Pack)(p))))
{
return invoker<Pack>(FIT_FORWARD(Pack)(p));
}

View File

@@ -11,6 +11,16 @@ struct auto_caster
}
};
template<class T>
struct auto_caster_noexcept
{
template<class U>
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_caster_noexcept> auto_cast{};
float f = 1.5;
static_assert(noexcept(int(auto_cast(f))), "noexcept implicit");
}
#endif