Re: definition of static member variables of a class template
On Feb 20, 7:00 pm, "Alf P. Steinbach" <al...@start.no> wrote:
* aaragon:
Hi everyone,
I've been using the following code with GNU C++ compiler for a long
time:
template <
class Class1,
class Class2
class calculator {
... // some type definitions
typedef std::map<KeyType, double> ConstantMapTyp=
e;
static ConstantMapType userConsts_;
... // the rest of the class is irrelev=
ant
};
Now, to initialize the static member variable, I had in the same
compilation unit:
template < class C1, class C2 >
typename calculator<C1,C2>::ConstantMapType
calculator<C1,C2>::userConsts_;
This has worked so far. Now I try to compile the same code with the
Intel C++ compiler, and I get
../cpputils/calculator.hpp(1449): error: declaration is incompatible
with "const calc::calculator<Class1, Class2>::ConstMap
calc::calculator<Class1, Class2>::constsMap_" (declared at line 260)
const typename calculator<C1,C2>::ConstMap
calculator<C1,C2>::constsMap_;
^
where ^ is actually pointing to constMap_. Someone can tell me what is
happening here? Why is the Intel compiler complaining about this code?
It looks like you have some 'const' keywords in the declaration in the cl=
ass.
Try to reproduce the problem in a smallest /complete/ example.
Cheers & hth.,
- Alf
Hi Alf, thanks for replying. I removed const from both the definition
and the declaration and the code compiled fine. This is weird though
because it was const in both places. Maybe there is a bug in the
compiler. Do you have any idea where this type of issues related to
Intel compiler can be discussed?
Thanks for replying once again,
aa