// CS 509 - Advanced Programming II
// Spring 2004
//
// An example of using callable expression templates with generic algorithms.
#include <iostream>
#include <functional>
#include <vector>
#include "ettc.h"
def_binexp(<, less)
def_binexp(||, logical_or)
template <class Temps>
static unsigned
abnormal_count(const Temps & temps) {
variable t;
return std::count_if(
temps.begin(), temps.end(),
(t < 97.6) || (99.6 < t));
}
int
main() {
result_type temps[] = { 95, 96, 97, 98, 99, 100, 101};
std::vector<result_type> t(temps, temps + sizeof(temps)/sizeof(result_type));
std::cout << abnormal_count(t)
<< " abnormal temperatures.\n";
}
// $Log: et-callable.cc,v $
// Revision 1.1 2004/05/06 19:43:14 rclayton
// Initial revision
//
syntax highlighted by Code2HTML, v. 0.9