Commit c0b79371 authored by Christos Stratopoulos's avatar Christos Stratopoulos Committed by Facebook Github Bot

Handle noexcept in SignatureOf_ and ArgTypes_, take 2 (#1178)

Summary:
Second attempt at https://github.com/facebook/folly/pull/1173

This time the class template specializations are guarded with the `__cpp_noexcept_function_type` feature test macro to maintain compatibility with C++14.

Open to replacing the raw macro with something like `FOLLY_POLY_NOEXCEPT_FUNCTION_TYPE` but that was not my first approach since it's more characters and there is not an extra case to test like with `FOLLY_POLY_NTTP_AUTO`.
Pull Request resolved: https://github.com/facebook/folly/pull/1178

Reviewed By: yfeldblum

Differential Revision: D16057403

Pulled By: Orvid

fbshipit-source-id: 9b538c0f1b0614e69447202d1e4d60ed3fa709cb
parent f22119f1
...@@ -404,6 +404,19 @@ struct SignatureOf_<R (C::*)(As...) const, I> { ...@@ -404,6 +404,19 @@ struct SignatureOf_<R (C::*)(As...) const, I> {
using type = Ret<R, I> (*)(Data const&, Arg<As, I>...); using type = Ret<R, I> (*)(Data const&, Arg<As, I>...);
}; };
#ifdef __cpp_noexcept_function_type
template <class R, class C, class... As, class I>
struct SignatureOf_<R (C::*)(As...) noexcept, I> {
using type = std::add_pointer_t<Ret<R, I>(Data&, Arg<As, I>...) noexcept>;
};
template <class R, class C, class... As, class I>
struct SignatureOf_<R (C::*)(As...) const noexcept, I> {
using type =
std::add_pointer_t<Ret<R, I>(Data const&, Arg<As, I>...) noexcept>;
};
#endif
template <class R, class This, class... As, class I> template <class R, class This, class... As, class I>
struct SignatureOf_<R (*)(This&, As...), I> { struct SignatureOf_<R (*)(This&, As...), I> {
using type = Ret<R, I> (*)(Data&, Arg<As, I>...); using type = Ret<R, I> (*)(Data&, Arg<As, I>...);
...@@ -425,6 +438,13 @@ struct ArgTypes_<User, I, Ret (*)(Data, Args...)> { ...@@ -425,6 +438,13 @@ struct ArgTypes_<User, I, Ret (*)(Data, Args...)> {
using type = TypeList<Args...>; using type = TypeList<Args...>;
}; };
#ifdef __cpp_noexcept_function_type
template <FOLLY_AUTO User, class I, class Ret, class Data, class... Args>
struct ArgTypes_<User, I, Ret (*)(Data, Args...) noexcept> {
using type = TypeList<Args...>;
};
#endif
template <FOLLY_AUTO User, class I> template <FOLLY_AUTO User, class I>
using ArgTypes = _t<ArgTypes_<User, I>>; using ArgTypes = _t<ArgTypes_<User, I>>;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment