首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::not_fn

Defined in header <functional>

template< class F> /*unspecified*/ not_fn( F&& f );

(since C++17)

创建一个转发调用包装器,该包装器返回它所持有的可调用对象的补码。

参数

f

-

the object from which the Callable object held by the wrapper is constructed

类型要求

-性病::腐烂[医]T型<F>必须满足可调用和可移动的要求。

-性病::IS[医]可构造[医]V<STD::衰变[医]T型<F>,F>必须为真。

返回值

未指定类型的函数对象T.它有以下成员:

STD:不[医]新军返回类型

成员对象

返回类型std::not_fn持有类型为的成员对象。std::decay_t<F>...

建设者

explicit T(F&& f);

(1)

T(T&& f) = default; T(const T& f) = default;

(2)

1%29构造函数初始化成员对象%28的类型std::decay_t<F>29%std::forward<F>(f)引发所选构造函数引发的任何异常。

2%29因为std::decay_t<F>必须是MoveConstructible,则返回的调用包装器总是MoveConstructible,而且是CopyConstructible如果std::decay_t<F>CopyConstructible...

成员函数operator()

template<class... Args> auto operator()(Args&&... args) & -> decltype(!std::declval<std::invoke_result_t<std::decay_t<F>&, Args...>>()); template<class... Args> auto operator()(Args&&... args) const& -> decltype(!std::declval<std::invoke_result_t<std::decay_t<F> const&, Args...>>());

(1)

template<class... Args> auto operator()(Args&&... args) && -> decltype(!std::declval<std::invoke_result_t<std::decay_t<F>, Args...>>()); template<class... Args> auto operator()(Args&&... args) const&& -> decltype(!std::declval<std::invoke_result_t<std::decay_t<F> const, Args...>>());

(2)

1%29相当于return!std::invoke(fd,std::forward<Args>(args)...)

2%29相当于return!std::invoke(std::move(fd),std::forward<Args>(args)...)

何地fd是std::衰减类型的成员对象。[医]T型<F>

例外

不抛出任何异常,除非fd扔。

注记

not_fn是为了取代C++03时代的消音器。std::not1std::not2...

另见

not1 (deprecated)

constructs custom std::unary_negate object (function template)

not2 (deprecated)

constructs custom std::binary_negate object (function template)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券