ivl 679
ivl::types::promote< T > Struct Template Reference

promote is used to promote T to a larger type More...

#include <evolution.hpp>

Inherits type< is_ivl_array< T >, to_type< promote< subtype< T >::type >::type, T >, to_type< T > >.


Detailed Description

template<class T>
struct ivl::types::promote< T >

promote is used to promote T to a larger type

This class is used to promote small integers to larger type integers and leaves all floating point types as they are. It is used to store the result of functions such as sum

A few details about this type. (Kimon) It is a hard decision to conclude on the promotions that will be made to each type. And this is because the need for promotion depends on the actual function that uses the promotion. Using a one-type-up promotion like in boost would be inadequate for most operations. For example summing up an array of 8-bit chars could easily produce a value larger than a 16-bit short, if we sum up more than 256 array elements. On the other hand, promoting to 64-bit long longs could seriously reduce performance if 64-bit operations are not supported by the compiler or host processor. So the following decision is made for the moment. The existing implementation of ivl I consider it to be a 32-bit library at its basis. If anyone would want numbers up to 64-bit high to perform an operation such as summing, they should have to write their own specialization of this function. This logic has some sense considering that 32-bit numbers usually cover the default image processing needs. *However* 32-bit ints are not explicitly stated in this promotion. The compiler-defined 'long' type is used instead. This is one more decision. The logic is the following. As for now (2009) Gcc and Visual Studio in 32-bit mode, where we work, treat long as a 32-bit integer. Any less than that wouldn't be implemeted by any new compiler. In the case that a compiler treats long as a larger type, e.g. 64-bit, would mean that 64-bit operations are totaly supported and therefore, such a promotion would be benefit. So I leave the decision for the promotion on the compiler.

The promotions are defined in the file ./platform_specific/promote_int_impl.hpp

so that any platform-specific treatment is made with #ifdef to make sure that all supported compilers work well with the defined specializations.


The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations