Group: comp.lang.c++
From: Christopher
Date: Thursday, April 10, 2008 5:37 PM
Subject: Re: how to call a template function that takes an enumerated type?

On Apr 10, 4:58 pm, aaragon wrote:
> Hello everyone,
>
> I run across this problem:
>
> I have a project that has a class with a template function, something
> like the following:
>
> class SomeClass {
> ...
> public:
> template
> inline typename PropertyTraits::PropertyType Map() {
> return boost::get(typename
> PropertyTraits::PropertyTag(), *g_);
> }
> ...
>
> };
>
> so you can see that this function takes an enumerated type:
>
> enum PROPERTY { POINT, WEIGHT};
>
> // define local classes
> template
> class PropertyTraits;
>
> template
> struct PropertyTraits {
> typedef vertex_point_t PropertyTag;
> typedef typename boost::property_map::type
> PropertyType;};
>
> template
> struct PropertyTraits {
> typedef edge_weight_t PropertyTag;
> typedef typename boost::property_map::type
> PropertyType;
>
> };
>
> Now, in some other code, I have a function template that takes as a
> template parameter an object that can be an object of SomeClass.
>
> class OtherClass {
> ...
> template
> void operator()(CL& c) {
> ...
> mvac_.template Map()
> ...
> }
> ...
>
> };
>
> Now, when I do this, the compiler says:
>
> domain.h:638: error: 'POINT' was not declared in this scope
>
> and this is ok because I don't want the code of OtherClass to know
> about any enumerated types or classes in the first project. I tried
> replacing POINT by 0 and it compiles, but then when I have to compile
> the original code I have:
>
> domain.h:638: error: no matching function for call to 'mvac::mVAC3<2,
> mvac::DomainTraits<2> >::Map()'
>
> Does anyone knows how can I call this template function? Thank you
> all,
>
> aa


Qualify the enumerated type? include the proper file?
Depends where it is defined... By what you have written I would assume
with low confidence that it is global? , but then I doubt you would be
getting the error.

You didn't clearly show where the enum was defined, filenames, or
where the error occured. I don't know where line 638 is in your pasted
code.

Safety Articles | Usenet Groups | 20lbs in 30 days