Chic documentation
Houlder Technologies


Scientific computing from the Blitz++ library
Home
Features
Tutorial
Examples
FAQ
Reference
Download
Mailing list
Contact

This example illustrates heavy use of templates. The code is a component taken from Blitz++, a library for scientific computing written by Todd Veldhuisen. The number of maintained source code lines in the converted files has been reduced with almost 30%. But more important than the number of source lines is the nature of the code that has been eliminated. In brief, instead of writing code like

// Header file.
template<class P_numtype2>
T_pick& operator=(const Vector<P_numtype2> &);

// Implementation file.
template<class P_numtype> template<class P_numtype2>
inline VectorPick<P_numtype>&
VectorPick<P_numtype>::
operator=(const Vector<P_numtype2>& x)
{
  (*this) = _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
  return *this;
}
you can write
// Hic file.
template<class P_numtype2>
inline T_pick& operator=(const Vector<P_numtype2> &)
{
  (*this) = _bz_VecExpr<VectorIterConst<P_numtype2> >(x.begin());
  return *this;
}

A macro that allows using Blitz++ with broken compilers that don't support namespaces has been expanded in the original code. You should not use Chic if you're stuck with such a compiler. Also, external include guards such as found in vecpick.h are redundant with a decent C++ compiler.

Original (slightly modified) code:

Converted file:

Automatically generated compile files (using default parameters):

Parameter file



Home