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:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user