I
iglpdc
Hi,
I need a template class taking several non-type arguments. Then I want
to be able to pass these arguments to the constructor of another non-
template class. So far I have this (I did some editing to simplify the
thing):
template<int const* rule_, double const* raw_oper_>
struct A{
static const int* rule() { return rule_; }
static const double* raw_oper() {return raw_oper_; }
};
I have the arrays defined with external linkage:
extern int const _rule[]={ 0, 1 };
extern double const _raw_oper[]={ 0.0, 1.0 };
A<_rule, _raw_oper> a;
struct B{
B(const int* rule, const double * raw_oper) { // create B with the
arrays };
// more stuff here
};
So far it's fine (I guess). This is pretty much the example on how to
use char const* arguments in page 110 of Vandevoorde & Josuttis book.
However if I do:
B b(a::rule(), a::raw_oper());
The compiler complains with something like:
operators.h:522: error: no matching function for call to 'B::B(const
double* (&)(), const int*)'
operators.h:366: note: candidates are: B::B(const double*, const
int*)
Why is there a difference in the way the array of int and the array of
double
are treated? How can I return the array variables to use them in other
parts of the code?
Many thanks in advance!
I need a template class taking several non-type arguments. Then I want
to be able to pass these arguments to the constructor of another non-
template class. So far I have this (I did some editing to simplify the
thing):
template<int const* rule_, double const* raw_oper_>
struct A{
static const int* rule() { return rule_; }
static const double* raw_oper() {return raw_oper_; }
};
I have the arrays defined with external linkage:
extern int const _rule[]={ 0, 1 };
extern double const _raw_oper[]={ 0.0, 1.0 };
A<_rule, _raw_oper> a;
struct B{
B(const int* rule, const double * raw_oper) { // create B with the
arrays };
// more stuff here
};
So far it's fine (I guess). This is pretty much the example on how to
use char const* arguments in page 110 of Vandevoorde & Josuttis book.
However if I do:
B b(a::rule(), a::raw_oper());
The compiler complains with something like:
operators.h:522: error: no matching function for call to 'B::B(const
double* (&)(), const int*)'
operators.h:366: note: candidates are: B::B(const double*, const
int*)
Why is there a difference in the way the array of int and the array of
double
are treated? How can I return the array variables to use them in other
parts of the code?
Many thanks in advance!