STIR  6.2.0
stir::detail::test_if_1d< Num_dimensions > Struct Template Reference

a templated class used to check if it's a 1D array or not This class only exists to allow a work-around for older compilers (such as VC 6.0) that do not implement partial ordering of function templates or partial template specialisation. More...

#include "stir/detail/test_if_1d.h"

Inheritance diagram for stir::detail::test_if_1d< Num_dimensions >:
Inheritance graph
[legend]

Detailed Description

template<int Num_dimensions>
struct stir::detail::test_if_1d< Num_dimensions >

a templated class used to check if it's a 1D array or not This class only exists to allow a work-around for older compilers (such as VC 6.0) that do not implement partial ordering of function templates or partial template specialisation.

For modern compilers one can write

// generic case
template <int n, class T> void f(Array<n,T>&);
// 1D case
template <class T> void f(Array<1,T>&);

The work-around is as follows

// generic case
template <int n, class T> void f_help(is_not_1d, Array<n,T>&);
// 1D case
template <class T> void f_help(is_1d, Array<1,T>&);
// function that will dispatch
template <int n, class T> void f(Array<n,T>& a)
{ f_help(test_if_1d<n>(), a); }

So, the same effect is achieved by having one extra function. Of course, the name f_help is arbitrary, and could just as well be f. However, it's best to hide these away from the user, as they should never be used explicitly.


The documentation for this struct was generated from the following file: