CGAL::Number_type_checker<NT1,NT2,Comparator>

Definition

Number_type_checker is a number type whose instances store two numbers of types NT1 and NT2. It forwards all arithmetic operations to them, and calls the binary predicate Comparator to check the equality of the instances after each modification, as well as for each comparison.

This is a debugging tool which is useful when dealing with number types.

Parameters

NT1 must be a model of some algebraic structure concept. NT2 must be a model of the same algebraic structure concept. NT1 and NT2 must be FromDoubleConstructible. Comparator has to be a model of a binary predicate taking NT1 as first argument, and NT2 as second. The Comparator parameter has a default value which is a functor calling operator== between the two arguments.

#include <CGAL/Number_type_checker.h>

Is Model for the Concepts

IntegralDomainWithoutDivision (same as NT1)
RealEmbeddable

Creation

Number_type_checker<NT1,NT2,Comparator> c;
introduces an uninitialized variable c.

Number_type_checker<NT1,NT2,Comparator> c ( int i);
introduces the integral value i.

Number_type_checker<NT1,NT2,Comparator> c ( double d);
introduces the floating point value d.

Number_type_checker<NT1,NT2,Comparator> c ( NT1 n1, NT2 n2);
introduces a variable storing the pair n1, n2.

Operations

Some operations have a particular behavior documented here.

NT1 c.n1 () returns a const reference to the object of type NT1.
NT2 c.n2 () returns a const reference to the object of type NT2.
NT1 & c.n1 () returns a reference to the object of type NT1.
NT2 & c.n2 () returns a reference to the object of type NT2.
bool c.is_valid () calls the Comparator binary predicate on the two stored objects and returns its result.

std::ostream& std::ostream& out << Number_type_checker c
writes c.n1() to the ostream out.

std::istream& std::istream& in >> Number_type_checker& c
reads an NT1 from in, then converts it to an NT2, so a conversion from NT1 to NT2 is required here.