Commit d57409cb by Jonathan Wakely Committed by Jonathan Wakely

Define macro to simplify std::_Not_fn definition

	* include/std/functional (_Not_fn): Define macro to simplify
	repetitive function definitions.

From-SVN: r246013
parent 4e0c6654
2017-03-09 Jonathan Wakely <jwakely@redhat.com> 2017-03-09 Jonathan Wakely <jwakely@redhat.com>
* include/std/functional (_Not_fn): Define macro to simplify
repetitive function definitions.
* doc/xml/manual/status_cxx2017.xml: Document std::byte support. * doc/xml/manual/status_cxx2017.xml: Document std::byte support.
* include/c_global/cstddef (std::byte): Define for C++17. * include/c_global/cstddef (std::byte): Define for C++17.
* testsuite/18_support/byte/global_neg.cc: New test. * testsuite/18_support/byte/global_neg.cc: New test.
......
...@@ -902,15 +902,12 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) ...@@ -902,15 +902,12 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
template<typename _Fn> template<typename _Fn>
class _Not_fn class _Not_fn
{ {
template<typename _Tp>
using __is_nothrow_negatable
= __bool_constant<noexcept(!std::declval<_Tp>())>;
template<typename _Fn2, typename... _Args> template<typename _Fn2, typename... _Args>
using __noexcept_cond = __and_< using __inv_res_t = result_of_t<_Fn2(_Args&&...)>;
__is_nothrow_callable<_Fn2(_Args&&...)>,
__is_nothrow_negatable<result_of_t<_Fn2(_Args&&...)>> template<typename _Tp>
>; static decltype(!std::declval<_Tp>())
_S_not() noexcept(noexcept(!std::declval<_Tp>()));
public: public:
template<typename _Fn2> template<typename _Fn2>
...@@ -921,39 +918,23 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) ...@@ -921,39 +918,23 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type)
_Not_fn(_Not_fn&& __fn) = default; _Not_fn(_Not_fn&& __fn) = default;
~_Not_fn() = default; ~_Not_fn() = default;
template<typename... _Args> // Macro to define operator() with given cv-qualifiers ref-qualifiers,
auto // forwarding _M_fn and the function arguments with the same qualifiers,
operator()(_Args&&... __args) & // and deducing the return type and exception-specification.
noexcept(__noexcept_cond<_Fn&, _Args&&...>::value) #define _GLIBCXX_NOT_FN_CALL_OP( _QUALS ) \
-> decltype(!std::declval<result_of_t<_Fn&(_Args&&...)>>()) template<typename... _Args> \
{ return !std::__invoke(_M_fn, std::forward<_Args>(__args)...); } decltype(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>()) \
operator()(_Args&&... __args) _QUALS \
template<typename... _Args> noexcept(noexcept(_S_not<__inv_res_t<_Fn _QUALS, _Args...>>())) \
auto { \
operator()(_Args&&... __args) const & return !std::__invoke(std::forward< _Fn _QUALS >(_M_fn), \
noexcept(__noexcept_cond<const _Fn&, _Args&&...>::value) std::forward<_Args>(__args)...); \
-> decltype(!std::declval<result_of_t<const _Fn&(_Args&&...)>>())
{ return !std::__invoke(_M_fn, std::forward<_Args>(__args)...); }
template<typename... _Args>
auto
operator()(_Args&&... __args) &&
noexcept(__noexcept_cond<_Fn&&, _Args&&...>::value)
-> decltype(!std::declval<result_of_t<_Fn&&(_Args&&...)>>())
{
return !std::__invoke(std::move(_M_fn),
std::forward<_Args>(__args)...);
}
template<typename... _Args>
auto
operator()(_Args&&... __args) const &&
noexcept(__noexcept_cond<const _Fn&&, _Args&&...>::value)
-> decltype(!std::declval<result_of_t<const _Fn&&(_Args&&...)>>())
{
return !std::__invoke(std::move(_M_fn),
std::forward<_Args>(__args)...);
} }
_GLIBCXX_NOT_FN_CALL_OP( & )
_GLIBCXX_NOT_FN_CALL_OP( const & )
_GLIBCXX_NOT_FN_CALL_OP( && )
_GLIBCXX_NOT_FN_CALL_OP( const && )
#undef _GLIBCXX_NOT_FN_CALL
private: private:
_Fn _M_fn; _Fn _M_fn;
......
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