Copyright (C) 2000-2012 |
Whole document tree unary_negate<AdaptablePredicate>
DescriptionUnary_negate is a function object adaptor: it is an Adaptable Predicate that represents the logical negation of some other Adaptable Predicate. That is: if f is an object of class unary_negate<AdaptablePredicate>, then there exists an object pred of class AdaptablePredicate such that f(x) always returns the same value as !pred(x). [1] There is rarely any reason to construct a unary_negate directly; it is almost always easier to use the helper function not1.ExampleFinds the first element in a list that does not lie in the range from 1 to 10.list<int> L; ... list<int>::iterator in_range = find_if(L.begin(), L.end(), not1(compose2(logical_and<bool>(), bind2nd(greater_equal<int>(), 1), bind2nd(less_equal<int>(), 10)))); assert(in_range == L.end() || !(*in_range >= 1 && *in_range <= 10)); DefinitionDefined in the standard header functional, and in the nonstandard backward-compatibility header function.h.Template parameters
Model ofAdaptable PredicateType requirementsAdaptablePredicate must be a model of Adaptable Predicate.Public base classesunary_function<AdaptablePredicate::argument_type, bool>Members
New membersThese members are not defined in the Adaptable Predicate requirements, but are specific to unary_negate.
Notes[1] Strictly speaking, unary_negate is redundant. It can be constructed using the function object logical_not and the adaptor unary_compose. See alsoThe function object overview, Adaptable Predicate, Predicate, binary_negate, unary_compose, binary_composeCopyright © 1999 Silicon Graphics, Inc. All Rights Reserved. TrademarkInformation
|