[GiNaC-list] [patch] fix template template declarations [GCC 4.2 compilation fix]

Sheplyakov Alexei varg at theor.jinr.ru
Wed Apr 19 14:10:15 CEST 2006


Hello!

The attached patch corrects template template declarations, so GiNaC can
be compiled with G++ 4.2. Without this patch compilation fails, see 
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=362220
for details.

Note that `make check' still fails with G++ 4.2.  Basically,

ex e("-1 + 2*I", symbol());

triggers an exception. My patch *does not* fix this error.

Best regards, 
  Alexei.

-- 
All science is either physics or stamp collecting.

-------------- next part --------------
Index: ginac/container.h
===================================================================
RCS file: /home/cvs/GiNaC/ginac/container.h,v
retrieving revision 1.16.2.2
diff -u -r1.16.2.2 container.h
--- ginac/container.h	1 May 2005 18:12:42 -0000	1.16.2.2
+++ ginac/container.h	19 Apr 2006 11:05:58 -0000
@@ -39,7 +39,7 @@
 
 
 /** Helper template for encapsulating the reserve() mechanics of STL containers. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 class container_storage {
 protected:
 	typedef C<ex> STLT;
@@ -125,7 +125,7 @@
 };
 
 /** Wrapper template for making GiNaC classes out of STL containers. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 class container : public basic, public container_storage<C> {
 	GINAC_DECLARE_REGISTERED_CLASS(container, basic)
 
@@ -452,14 +452,14 @@
 };
 
 /** Default constructor */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 container<C>::container() : inherited(get_tinfo())
 {
 	setflag(get_default_flags());
 }
 
 /** Construct object from archive_node. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 container<C>::container(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
 	setflag(get_default_flags());
@@ -474,14 +474,14 @@
 }
 
 /** Unarchive the object. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 ex container<C>::unarchive(const archive_node &n, lst &sym_lst)
 {
 	return (new container(n, sym_lst))->setflag(status_flags::dynallocated);
 }
 
 /** Archive the object. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 void container<C>::archive(archive_node &n) const
 {
 	inherited::archive(n);
@@ -492,14 +492,14 @@
 	}
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 void container<C>::do_print(const print_context & c, unsigned level) const
 {
 	// always print brackets around seq, ignore upper_precedence
 	printseq(c, get_open_delim(), ',', get_close_delim(), precedence(), precedence()+1);
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 void container<C>::do_print_tree(const print_tree & c, unsigned level) const
 {
 	c.s << std::string(level, ' ') << class_name() << " @" << this
@@ -514,20 +514,20 @@
 	c.s << std::string(level + c.delta_indent,' ') << "=====" << std::endl;
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 void container<C>::do_print_python(const print_python & c, unsigned level) const
 {
 	printseq(c, '[', ',', ']', precedence(), precedence()+1);
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 void container<C>::do_print_python_repr(const print_python_repr & c, unsigned level) const
 {
 	c.s << class_name();
 	printseq(c, '(', ',', ')', precedence(), precedence()+1);
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 ex container<C>::op(size_t i) const
 {
 	GINAC_ASSERT(i < nops());
@@ -537,7 +537,7 @@
 	return *it;
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 ex & container<C>::let_op(size_t i)
 {
 	GINAC_ASSERT(i < nops());
@@ -548,7 +548,7 @@
 	return *it;
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 ex container<C>::eval(int level) const
 {
 	if (level == 1)
@@ -557,7 +557,7 @@
 		return thiscontainer(evalchildren(level));
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 ex container<C>::subs(const exmap & m, unsigned options) const
 {
 	std::auto_ptr<STLT> vp = subschildren(m, options);
@@ -568,7 +568,7 @@
 }
 
 /** Compare two containers of the same type. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 int container<C>::compare_same_type(const basic & other) const
 {
 	GINAC_ASSERT(is_a<container>(other));
@@ -587,7 +587,7 @@
 	return (it1 == it1end) ? (it2 == it2end ? 0 : -1) : 1;
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 bool container<C>::is_equal_same_type(const basic & other) const
 {
 	GINAC_ASSERT(is_a<container>(other));
@@ -607,7 +607,7 @@
 }
 
 /** Add element at front. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 container<C> & container<C>::prepend(const ex & b)
 {
 	ensure_if_modifiable();
@@ -616,7 +616,7 @@
 }
 
 /** Add element at back. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 container<C> & container<C>::append(const ex & b)
 {
 	ensure_if_modifiable();
@@ -625,7 +625,7 @@
 }
 
 /** Remove first element. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 container<C> & container<C>::remove_first()
 {
 	ensure_if_modifiable();
@@ -634,7 +634,7 @@
 }
 
 /** Remove last element. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 container<C> & container<C>::remove_last()
 {
 	ensure_if_modifiable();
@@ -643,7 +643,7 @@
 }
 
 /** Remove all elements. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 container<C> & container<C>::remove_all()
 {
 	ensure_if_modifiable();
@@ -652,7 +652,7 @@
 }
 
 /** Sort elements. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 container<C> & container<C>::sort()
 {
 	ensure_if_modifiable();
@@ -667,7 +667,7 @@
 }
 
 /** Remove adjacent duplicate elements. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 container<C> & container<C>::unique()
 {
 	ensure_if_modifiable();
@@ -676,7 +676,7 @@
 }
 
 /** Print sequence of contained elements. */
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 void container<C>::printseq(const print_context & c, char openbracket, char delim,
                             char closebracket, unsigned this_precedence,
                             unsigned upper_precedence) const
@@ -699,7 +699,7 @@
 		c.s << closebracket;
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 typename container<C>::STLT container<C>::evalchildren(int level) const
 {
 	if (level == 1)
@@ -720,7 +720,7 @@
 	return s;
 }
 
-template <template <class> class C>
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class C>
 std::auto_ptr<typename container<C>::STLT> container<C>::subschildren(const exmap & m, unsigned options) const
 {
 	// returns a NULL pointer if nothing had to be substituted
Index: ginac/registrar.h
===================================================================
RCS file: /home/cvs/GiNaC/ginac/registrar.h,v
retrieving revision 1.22.4.2
diff -u -r1.22.4.2 registrar.h
--- ginac/registrar.h	1 May 2005 18:12:43 -0000	1.22.4.2
+++ ginac/registrar.h	19 Apr 2006 11:05:59 -0000
@@ -26,6 +26,7 @@
 #include <string>
 #include <list>
 #include <vector>
+#include <memory>
 
 #include "class_info.h"
 #include "print.h"
@@ -35,7 +36,7 @@
 class ex;
 class archive_node;
 
-template <template <class> class> class container;
+template <template <typename ELEM, typename ALLOC = std::allocator<ELEM> > class> class container;
 typedef container<std::list> lst;
 
 
Index: ginsh/ginsh_parser.yy
===================================================================
RCS file: /home/cvs/GiNaC/ginsh/ginsh_parser.yy,v
retrieving revision 1.77.2.4
diff -u -r1.77.2.4 ginsh_parser.yy
--- ginsh/ginsh_parser.yy	11 Sep 2005 22:37:48 -0000	1.77.2.4
+++ ginsh/ginsh_parser.yy	19 Apr 2006 11:05:59 -0000
+namespace GiNaC {
 // All registered GiNaC functions
-void GiNaC::ginsh_get_ginac_functions(void)
+void ginsh_get_ginac_functions(void)
 {
 	vector<function_options>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
 	unsigned serial = 0;
@@ -712,6 +725,7 @@
 		serial++;
 	}
 }
+}
 
 
 /*
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20060419/088aa1d3/attachment.pgp


More information about the GiNaC-list mailing list