View Template Library

is_nonzero<T>

Category: functors

Component type: type

Description

is_nonzero<T> is a function object. Specifically, it is an Adaptable Predicate, which means it is a function object that tests the truth or falsehood of some condition. If f is an object of class is_nonzero<T> and x is an object of class T, then f(x) returns true if x != 0 and false otherwise.

Example

Finds the first zero element in a list.

list<int> L;
...
list<int>::iterator first_nonzero = 
       find_if(L.begin(), L.end(),is_nonzero<int>());
assert(first_nonzero == L.end() || *first_nonzero == 0);

Definition

Defined in functors.hpp.

Template parameters

Parameter

Description

Default

T

The type of is_nonzero's arguments.


Model of

Adaptable Predicate, DefaultConstructible

Type requirements

T is is_nonzeroThan Comparable.

Public base classes

unary_function<T,bool>.

Members

Member

Where defined

Description

argument_type

Adaptable Predicate

The type of the argument: T

result_type

Adaptable Predicate

The type of the result: bool

is_nonzero()

DefaultConstructible

The default constructor.

bool operator()(const T& x)

Unary Function

Function call operator. The return value is x != 0.

New members

All of is_nonzero's members are defined in the Adaptable Predicate and DefaultConstructible requirements. is_nonzero does not introduce any new members.

Notes

See also

The function object overview, Adaptable Predicate


VTL Home
Copyright © 1999, 2000 Konrad-Zuse-Zentrum für Informationstechnik Berlin & Gary Powell All Rights Reserved.