negate函数

Negate 函数对时间系列求反

它是对时间系列起作用的一种一元算术函数。其他一元算术函数包括: Abs、Acos、Asin、Atan、Cos、Exp、Logn、Positive、Round、Sin、Sqrt 和 Tan。

语法

template<typename Arg>  
    ref class negate  
    { // wrap operator()  
public:  
    typedef Arg argument_type;  
    typedef bool result_type;  
    typedef Microsoft::VisualC::StlClr::UnaryDelegate<  
        argument_type, result_type>  
        delegate_type;  

    negate();  
    negate(negate<Arg>% right);  

    result_type operator()(argument_type left);  
    operator delegate_type^();  
    };  

参数
Arg
参数类型。

类型定义 说明
类型变量 仿函数参数的类型。
委托类型 泛型委托的类型。
结果类型 仿函数结果的类型 。


成员 说明
negate 构造仿函数。


运算符 说明
operator() 计算所需函数数量。
运算符 delegate_type^ 转换仿函数为委托。

备注

模板类描述带有一个参数的仿函数。 它定义成员运算符 operator(),这样,当对象被调用作为函数时,它返回对其否定参数。也可以传递对象作为类型为 delegate_type^ 的函数参数,并将相应地转换。

示例

// cliext_negate.cpp   
// compile with: /clr   
#include <cliext/algorithm>   
#include <cliext/functional>   
#include <cliext/vector>   

typedef cliext::vector<int> Myvector;   
int main()   
    {   
    Myvector c1;   
    c1.push_back(4);   
    c1.push_back(-3);   
    Myvector c3(2, 0);   

// display initial contents " 4 -3"   
    for each (int elem in c1)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   

// transform and display   
    cliext::transform(c1.begin(), c1.begin() + 2,   
        c3.begin(), cliext::negate<int>());   
    for each (int elem in c3)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
    return (0);   
    }  

要求

Header:

命名空间: cliext

请参阅

logical_not

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值