+2016-10-05 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/70564
+ * include/experimental/functional (_Not_fn): Remove.
+ (not_fn): Use std::_Not_fn.
+ * include/std/functional (_Not_fn): Add second parameter to
+ disambiguate copying from initialization by not_fn. Define for C++14.
+ (not_fn): Add second argument to initialization.
+ * testsuite/20_util/not_fn/1.cc: Copy call wrapper using
+ direct-initialization.
+
2016-10-03 François Dumont <fdumont@gcc.gnu.org>
* src/c++11/shared_ptr.cc (mask, invalid, get_mutex): Move
#define __cpp_lib_experimental_not_fn 201406
- /// Generalized negator.
- template<typename _Fn>
- class _Not_fn
- {
- _Fn _M_fn;
-
- public:
- template<typename _Fn2>
- explicit
- _Not_fn(_Fn2&& __fn)
- : _M_fn(std::forward<_Fn2>(__fn)) { }
-
- _Not_fn(const _Not_fn& __fn) = default;
- _Not_fn(_Not_fn&& __fn) = default;
- ~_Not_fn() = default;
-
- template<typename... _Args>
- auto
- operator()(_Args&&... __args) &
- noexcept(__is_nothrow_callable<_Fn&(_Args&&...)>::value)
- -> decltype(!std::declval<result_of_t<_Fn&(_Args&&...)>>())
- { return !std::__invoke(_M_fn, std::forward<_Args>(__args)...); }
-
- template<typename... _Args>
- auto
- operator()(_Args&&... __args) const &
- noexcept(__is_nothrow_callable<const _Fn&(_Args&&...)>::value)
- -> 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(__is_nothrow_callable<_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(__is_nothrow_callable<const _Fn&&(_Args&&...)>::value)
- -> decltype(!std::declval<result_of_t<const _Fn&&(_Args&&...)>>())
- {
- return !std::__invoke(std::move(_M_fn),
- std::forward<_Args>(__args)...);
- }
- };
-
/// [func.not_fn] Function template not_fn
template<typename _Fn>
inline auto
not_fn(_Fn&& __fn)
noexcept(std::is_nothrow_constructible<std::decay_t<_Fn>, _Fn&&>::value)
{
- return _Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn)};
+ return std::_Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn), 0};
}
_GLIBCXX_END_NAMESPACE_VERSION
swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y) noexcept
{ __x.swap(__y); }
-
-#if __cplusplus > 201402L
-
-#define __cpp_lib_not_fn 201603
-
- /// Generalized negator.
+#if __cplusplus >= 201402L
+ /// Generalized negator.
template<typename _Fn>
class _Not_fn
{
public:
template<typename _Fn2>
- explicit
- _Not_fn(_Fn2&& __fn)
+ _Not_fn(_Fn2&& __fn, int)
: _M_fn(std::forward<_Fn2>(__fn)) { }
_Not_fn(const _Not_fn& __fn) = default;
template<typename... _Args>
auto
operator()(_Args&&... __args) &
- noexcept(is_nothrow_callable_v<_Fn&(_Args&&...)>)
+ noexcept(__is_nothrow_callable<_Fn&(_Args&&...)>::value)
-> decltype(!std::declval<result_of_t<_Fn&(_Args&&...)>>())
{ return !std::__invoke(_M_fn, std::forward<_Args>(__args)...); }
template<typename... _Args>
auto
operator()(_Args&&... __args) const &
- noexcept(is_nothrow_callable_v<const _Fn&(_Args&&...)>)
+ noexcept(__is_nothrow_callable<const _Fn&(_Args&&...)>::value)
-> 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(is_nothrow_callable_v<_Fn&&(_Args&&...)>)
+ noexcept(__is_nothrow_callable<_Fn&&(_Args&&...)>::value)
-> decltype(!std::declval<result_of_t<_Fn&&(_Args&&...)>>())
{
return !std::__invoke(std::move(_M_fn),
template<typename... _Args>
auto
operator()(_Args&&... __args) const &&
- noexcept(is_nothrow_callable_v<const _Fn&&(_Args&&...)>)
+ noexcept(__is_nothrow_callable<const _Fn&&(_Args&&...)>::value)
-> decltype(!std::declval<result_of_t<const _Fn&&(_Args&&...)>>())
{
return !std::__invoke(std::move(_M_fn),
private:
_Fn _M_fn;
};
+#endif // C++14
+
+#if __cplusplus > 201402L
+
+#define __cpp_lib_not_fn 201603
/// [func.not_fn] Function template not_fn
template<typename _Fn>
not_fn(_Fn&& __fn)
noexcept(std::is_nothrow_constructible<std::decay_t<_Fn>, _Fn&&>::value)
{
- return _Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn)};
+ return _Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn), 0};
}
// Searchers
return std::make_pair(__last, __last);
}
-#endif
+#endif // C++17
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std