less (STL/CLR)

描述模板类,那么,当调用,则返回 true 的 functor,只有第一参数比第二个小于。 使用该指定函数对象根据其参数类型。

template<typename Arg>
    ref class less
    { // wrap operator()
public:
    typedef Arg first_argument_type;
    typedef Arg second_argument_type;
    typedef bool result_type;
    typedef Microsoft::VisualC::StlClr::BinaryDelegate<
        first_argument_type, second_argument_type, result_type>
        delegate_type;

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

    result_type operator()(first_argument_type left,
        second_argument_type right);
    operator delegate_type^();
    };

参数

  • Arg
    参数的类型。

成员函数

类型定义

说明

delegate_type

泛型委托的类型。

first_argument_type

functor 第一个参数的类型。

result_type

functor 结果的类型。

second_argument_type

functor 第二个参数的类型。

成员

说明

less

构造 functor。

运算符

说明

operator()

计算所需的函数。

运算符 delegate_type^

转换 functor 为委托。

备注

模板类描述两参数 functor。 它定义成员运算符 operator(),这样,当调用对象,作为函数时,它将返回 true,只有第一参数比第二个小于。

还可以传递一个对象,因为类型为 delegate_type^ 的函数参数,并将相应地转换。

示例

// cliext_less.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 c2; 
    c2.push_back(4); 
    c2.push_back(4); 
    Myvector c3(2, 0); 
 
// display initial contents " 4 3" and " 4 4" 
    for each (int elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
    for each (int elem in c2) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// transform and display 
    cliext::transform(c1.begin(), c1.begin() + 2, 
        c2.begin(), c3.begin(), cliext::less<int>()); 
    for each (int elem in c3) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
  

要求

页眉: </cliext 功能>

命名空间: cliext

请参见

参考

greater_equal (STL/CLR)