Templates and combinatorial maps

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Templates and combinatorial maps

Yan Garito
Hello,

I'm having some trouble using combinatorial maps alongside templates. Here's the situation: I have a class A that contains a combinatorial map as an attribute and I want to template A by a number type, which is the information I want the edges of the combinatorial map to store. However, this results in compiler errors when trying to iterate over the attributes. Untemplating and hard coding the number type "fixes" the problem.
See the attached files for a minimum example of the problem. My compiler is g++, and my OS is Ubuntu 18. I did not tweak the Makefile generated with the CGAL scripts.

Thank you in advance,
Yan Garito,
First year DIT student at ENS Rennes

Minimal.tar.gz (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Templates and combinatorial maps

Guillaume Damiand
Hi Yan;


Le 12/06/2019 à 11:31, Yan Garito a écrit :
Hello,

I'm having some trouble using combinatorial maps alongside templates. Here's the situation: I have a class A that contains a combinatorial map as an attribute and I want to template A by a number type, which is the information I want the edges of the combinatorial map to store. However, this results in compiler errors when trying to iterate over the attributes. Untemplating and hard coding the number type "fixes" the problem.
See the attached files for a minimum example of the problem. My compiler is g++, and my OS is Ubuntu 18. I did not tweak the Makefile generated with the CGAL scripts.


The errors comes from a "strange" C++ rule. When you call a template method in a template class, you need to use the keyword template.


In your minimal example, you should write:


           for (Edge_attrib_iterator
             it = cm.template attributes<1>().begin(),
             itend = cm.template attributes<1>().end(); it != itend; ++it)
           {
            std::cout<< cm.template info_of_attribute<1>(it) <<"; ";
           }


Best

Guillaume




Thank you in advance,
Yan Garito,
First year DIT student at ENS Rennes


-- 
===================================================================
Guillaume DAMIAND

CNRS - LIRIS UMR 5205
Université Claude Bernard
Bâtiment Nautibus (710)
43 Boulevard du 11 Novembre 1918
69622 Villeurbanne Cedex (France)
-------------------------------------------------------------------
Tél: +33 (0)4.72.43.14.34                 Fax: +33 (0)4.72.43.15.36
Mail: [hidden email]
Web: http://liris.cnrs.fr/guillaume.damiand/
===================================================================

smime.p7s (3K) Download Attachment