D
David Carricajo
Hi,
For the sake of clarity i use abbreviations of my original problem,
i'm using boost::test along with boot::units to checks operations over
types:
//new types
typedef quantity<electric_potential,complex_type> tPotential;
typedef quantity<current,complex_type> tCurrent;
//generic operations
template<class T>
void BOOST_CHECK_MATRIX_EQUAL(const T t, const T v);
template<class T>
void BOOST_CHECK_MATRIX_EQUAL(const someArray<quantity<T> > t, const
someArray<quantity<T> > v);
template<>
void BOOST_CHECK_MATRIX_EQUAL<double>(const someOtherArray<double> t,
const someArray<double> v);
I use both types and operations over several compilation units, thus i
should only define templates in .cpp files, in the header files i
declare both templates and pointers to template functions, but in
defining pointers to template functions i lose the template argument
lookup:
typedef (*BOOST_CHECK_MATRIX_EQUAL_TYPE)(const someArray<tCurrent>,
const someArray<tCurrent>);
BOOST_CHECK_MATRIX_EQUAL_TYPE pCHECK_MATRIX = *
BOOST_CHECK_MATRIX_EQUAL<tCurrent>;
tSomeArray someArray<tCurrent> i1, i2;
BOOST_CHECK_MATRIX_EQUAL_TYPE(i1, i2); //ok,
tSomeOtherArray someOtherArray<tPotential> u1, u2;
BOOST_CHECK_MATRIX_EQUAL_TYPE(u1, u2); //obvious error
Since c++ lacks typedef templates and i'd like to span my code over
several compilation units, also i find it hard to change all of my
source code to change names of functions according to their
parameters. I don't find any way to let compiler instantiate the
correct function it should invoke. What would i try instead?
Much appreciated
For the sake of clarity i use abbreviations of my original problem,
i'm using boost::test along with boot::units to checks operations over
types:
//new types
typedef quantity<electric_potential,complex_type> tPotential;
typedef quantity<current,complex_type> tCurrent;
//generic operations
template<class T>
void BOOST_CHECK_MATRIX_EQUAL(const T t, const T v);
template<class T>
void BOOST_CHECK_MATRIX_EQUAL(const someArray<quantity<T> > t, const
someArray<quantity<T> > v);
template<>
void BOOST_CHECK_MATRIX_EQUAL<double>(const someOtherArray<double> t,
const someArray<double> v);
I use both types and operations over several compilation units, thus i
should only define templates in .cpp files, in the header files i
declare both templates and pointers to template functions, but in
defining pointers to template functions i lose the template argument
lookup:
typedef (*BOOST_CHECK_MATRIX_EQUAL_TYPE)(const someArray<tCurrent>,
const someArray<tCurrent>);
BOOST_CHECK_MATRIX_EQUAL_TYPE pCHECK_MATRIX = *
BOOST_CHECK_MATRIX_EQUAL<tCurrent>;
tSomeArray someArray<tCurrent> i1, i2;
BOOST_CHECK_MATRIX_EQUAL_TYPE(i1, i2); //ok,
tSomeOtherArray someOtherArray<tPotential> u1, u2;
BOOST_CHECK_MATRIX_EQUAL_TYPE(u1, u2); //obvious error
Since c++ lacks typedef templates and i'd like to span my code over
several compilation units, also i find it hard to change all of my
source code to change names of functions according to their
parameters. I don't find any way to let compiler instantiate the
correct function it should invoke. What would i try instead?
Much appreciated