]> www.ginac.de Git - ginac.git/blobdiff - ginac/container.h
Happy New Year!
[ginac.git] / ginac / container.h
index 3c1ac47eb688356fcd740f93149c358b1959715b..960f07297541f481d9968f74788b3c1f20a13550 100644 (file)
@@ -3,7 +3,7 @@
  *  Wrapper template for making GiNaC classes out of STL containers. */
 
 /*
- *  GiNaC Copyright (C) 1999-2015 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2019 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
 #include "print.h"
 #include "archive.h"
 #include "assertion.h"
+#include "compiler.h"
 
 #include <algorithm>
 #include <iterator>
 namespace GiNaC {
 
 /** Helper template for encapsulating the reserve() mechanics of STL containers. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 class container_storage {
 protected:
        typedef C<ex> STLT;
 
        container_storage() {}
        container_storage(size_t n, const ex & e) : seq(n, e) {}
+       container_storage(std::initializer_list<ex> il) : seq(il) {}
 
        template <class In>
        container_storage(In b, In e) : seq(b, e) {}
@@ -124,7 +126,7 @@ private:
 };
 
 /** Wrapper template for making GiNaC classes out of STL containers. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 class container : public basic, public container_storage<C> {
        GINAC_DECLARE_REGISTERED_CLASS(container, basic)
 protected:
@@ -160,207 +162,52 @@ public:
                setflag(get_default_flags());
        }
 
-       explicit container(const ex & p1)
-        : container_storage<C>(1, p1)
+       container(std::initializer_list<ex> il)
+        : container_storage<C>(il)
        {
                setflag(get_default_flags());
        }
 
-       container(const ex & p1, const ex & p2)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 2);
-               this->seq.push_back(p1); this->seq.push_back(p2);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 3);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 4);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 5);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 6);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6,
-                 const ex & p7)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 7);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-               this->seq.push_back(p7);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6,
-                 const ex & p7, const ex & p8)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 8);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-               this->seq.push_back(p7); this->seq.push_back(p8);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6,
-                 const ex & p7, const ex & p8, const ex & p9)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 9);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-               this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6,
-                 const ex & p7, const ex & p8, const ex & p9,
-                 const ex & p10)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 10);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-               this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9);
-               this->seq.push_back(p10);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6,
-                 const ex & p7, const ex & p8, const ex & p9,
-                 const ex & p10, const ex & p11)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 11);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-               this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9);
-               this->seq.push_back(p10); this->seq.push_back(p11);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6,
-                 const ex & p7, const ex & p8, const ex & p9,
-                 const ex & p10, const ex & p11, const ex & p12)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 12);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-               this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9);
-               this->seq.push_back(p10); this->seq.push_back(p11); this->seq.push_back(p12);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6,
-                 const ex & p7, const ex & p8, const ex & p9,
-                 const ex & p10, const ex & p11, const ex & p12,
-                 const ex & p13)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 13);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-               this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9);
-               this->seq.push_back(p10); this->seq.push_back(p11); this->seq.push_back(p12);
-               this->seq.push_back(p13);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6,
-                 const ex & p7, const ex & p8, const ex & p9,
-                 const ex & p10, const ex & p11, const ex & p12,
-                 const ex & p13, const ex & p14)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 14);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-               this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9);
-               this->seq.push_back(p10); this->seq.push_back(p11); this->seq.push_back(p12);
-               this->seq.push_back(p13); this->seq.push_back(p14);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6,
-                 const ex & p7, const ex & p8, const ex & p9,
-                 const ex & p10, const ex & p11, const ex & p12,
-                 const ex & p13, const ex & p14, const ex & p15)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 15);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-               this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9);
-               this->seq.push_back(p10); this->seq.push_back(p11); this->seq.push_back(p12);
-               this->seq.push_back(p13); this->seq.push_back(p14); this->seq.push_back(p15);
-       }
-
-       container(const ex & p1, const ex & p2, const ex & p3,
-                 const ex & p4, const ex & p5, const ex & p6,
-                 const ex & p7, const ex & p8, const ex & p9,
-                 const ex & p10, const ex & p11, const ex & p12,
-                 const ex & p13, const ex & p14, const ex & p15,
-                 const ex & p16)
-       {
-               setflag(get_default_flags());
-               this->reserve(this->seq, 16);
-               this->seq.push_back(p1); this->seq.push_back(p2); this->seq.push_back(p3);
-               this->seq.push_back(p4); this->seq.push_back(p5); this->seq.push_back(p6);
-               this->seq.push_back(p7); this->seq.push_back(p8); this->seq.push_back(p9);
-               this->seq.push_back(p10); this->seq.push_back(p11); this->seq.push_back(p12);
-               this->seq.push_back(p13); this->seq.push_back(p14); this->seq.push_back(p15);
-               this->seq.push_back(p16);
-       }
+       explicit container(const ex & p1) attribute_deprecated;
+       container(const ex & p1, const ex & p2) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                 const ex & p9) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                 const ex & p9, const ex & p10) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                 const ex & p9, const ex & p10, const ex & p11) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                 const ex & p9, const ex & p10, const ex & p11, const ex & p12) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                 const ex & p9, const ex & p10, const ex & p11, const ex & p12, const ex & p13) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                 const ex & p9, const ex & p10, const ex & p11, const ex & p12, const ex & p13, const ex & p14) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                 const ex & p9, const ex & p10, const ex & p11, const ex & p12, const ex & p13, const ex & p14, const ex & p15) attribute_deprecated;
+       container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                 const ex & p9, const ex & p10, const ex & p11, const ex & p12, const ex & p13, const ex & p14, const ex & p15, const ex & p16) attribute_deprecated;
 
        // First step of initialization of container with a comma-separated
        // sequence of expressions. Subsequent steps are handled by
        // container_init<>::operator,().
-       container_init<ex, STLT> operator=(const ex & x)
-       {
-               this->seq.push_back(x);
-               return container_init<ex, STLT>(this->seq);
-       }
+       container_init<ex, STLT> operator=(const ex & x) attribute_deprecated;
 
        // functions overriding virtual functions from base classes
 public:
-       bool info(unsigned inf) const { return inherited::info(inf); }
-       unsigned precedence() const { return 10; }
-       size_t nops() const { return this->seq.size(); }
-       ex op(size_t i) const;
-       ex & let_op(size_t i);
-       ex eval(int level = 0) const;
-       ex subs(const exmap & m, unsigned options = 0) const;
-
-       void read_archive(const archive_node &n, lst &sym_lst) 
+       bool info(unsigned inf) const override { return inherited::info(inf); }
+       unsigned precedence() const override { return 10; }
+       size_t nops() const override { return this->seq.size(); }
+       ex op(size_t i) const override;
+       ex & let_op(size_t i) override;
+       ex subs(const exmap & m, unsigned options = 0) const override;
+
+       void read_archive(const archive_node &n, lst &sym_lst) override
        {
                inherited::read_archive(n, sym_lst);
                setflag(get_default_flags());
@@ -377,7 +224,7 @@ public:
        }
 
        /** Archive the object. */
-       void archive(archive_node &n) const
+       void archive(archive_node &n) const override
        {
                inherited::archive(n);
                for (auto & i : this->seq) {
@@ -386,7 +233,7 @@ public:
        }
 
 protected:
-       ex conjugate() const
+       ex conjugate() const override
        {
                STLT *newcont = nullptr;
                for (const_iterator i=this->seq.begin(); i!=this->seq.end(); ++i) {
@@ -413,7 +260,7 @@ protected:
                return *this;
        }
 
-       ex real_part() const
+       ex real_part() const override
        {
                STLT cont;
                this->reserve(cont, nops());
@@ -424,7 +271,7 @@ protected:
                return thiscontainer(cont);
        }
 
-       ex imag_part() const
+       ex imag_part() const override
        {
                STLT cont;
                this->reserve(cont, nops());
@@ -435,7 +282,7 @@ protected:
                return thiscontainer(cont);
        }
 
-       bool is_equal_same_type(const basic & other) const;
+       bool is_equal_same_type(const basic & other) const override;
 
        // new virtual functions which can be overridden by derived classes
 protected:
@@ -488,26 +335,103 @@ protected:
        void do_print_tree(const print_tree & c, unsigned level) const;
        void do_print_python(const print_python & c, unsigned level) const;
        void do_print_python_repr(const print_python_repr & c, unsigned level) const;
-       STLT evalchildren(int level) const;
        STLT subschildren(const exmap & m, unsigned options = 0) const;
 };
 
 /** Default constructor */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 container<C>::container()
 {
        setflag(get_default_flags());
 }
 
+/** Deprecatd constructors (prefer initializer list) */
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1)
+  : container_storage<C>(1, p1) { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2)
+  : container_storage<C>{p1, p2} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3)
+  : container_storage<C>{p1, p2, p3} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4)
+  : container_storage<C>{p1, p2, p3, p4} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5)
+  : container_storage<C>{p1, p2, p3, p4, p5} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6, p7} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6, p7, p8} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                        const ex & p9)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6, p7, p8, p9} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                        const ex & p9, const ex & p10)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6, p7, p8, p9, p10} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                        const ex & p9, const ex & p10, const ex & p11)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                        const ex & p9, const ex & p10, const ex & p11, const ex & p12)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                        const ex & p9, const ex & p10, const ex & p11, const ex & p12, const ex & p13)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                        const ex & p9, const ex & p10, const ex & p11, const ex & p12, const ex & p13, const ex & p14)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                        const ex & p9, const ex & p10, const ex & p11, const ex & p12, const ex & p13, const ex & p14, const ex & p15)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15} { setflag(get_default_flags()); }
+template <template <class T, class = std::allocator<T>> class C>
+container<C>::container(const ex & p1, const ex & p2, const ex & p3, const ex & p4, const ex & p5, const ex & p6, const ex & p7, const ex & p8,
+                        const ex & p9, const ex & p10, const ex & p11, const ex & p12, const ex & p13, const ex & p14, const ex & p15, const ex & p16)
+  : container_storage<C>{p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16} { setflag(get_default_flags()); }
+
+template <template <class T, class = std::allocator<T>> class C>
+container_init<ex, typename container_storage<C>::STLT> container<C>::operator=(const ex & x)
+{
+       this->seq.push_back(x);
+       return container_init<ex, typename container_storage<C>::STLT>(this->seq);
+}
 
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> 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 T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 void container<C>::do_print_tree(const print_tree & c, unsigned level) const
 {
        c.s << std::string(level, ' ') << class_name() << " @" << this
@@ -522,20 +446,20 @@ void container<C>::do_print_tree(const print_tree & c, unsigned level) const
        c.s << std::string(level + c.delta_indent,' ') << "=====" << std::endl;
 }
 
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 void container<C>::do_print_python(const print_python & c, unsigned level) const
 {
        printseq(c, '[', ',', ']', precedence(), precedence()+1);
 }
 
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> 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 T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 ex container<C>::op(size_t i) const
 {
        GINAC_ASSERT(i < nops());
@@ -545,7 +469,7 @@ ex container<C>::op(size_t i) const
        return *it;
 }
 
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 ex & container<C>::let_op(size_t i)
 {
        GINAC_ASSERT(i < nops());
@@ -556,16 +480,7 @@ ex & container<C>::let_op(size_t i)
        return *it;
 }
 
-template <template <class T, class = std::allocator<T> > class C>
-ex container<C>::eval(int level) const
-{
-       if (level == 1)
-               return hold();
-       else
-               return thiscontainer(evalchildren(level));
-}
-
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 ex container<C>::subs(const exmap & m, unsigned options) const
 {
        // After having subs'ed all children, this method subs'es one final
@@ -579,12 +494,12 @@ ex container<C>::subs(const exmap & m, unsigned options) const
        STLT subsed = subschildren(m, options);
        if (!subsed.empty()) {
                ex result(thiscontainer(subsed));
-               if (is_a<container<C> >(result))
+               if (is_a<container<C>>(result))
                        return ex_to<basic>(result).subs_one_level(m, options);
                else
                        return result;
        } else {
-               if (is_a<container<C> >(*this))
+               if (is_a<container<C>>(*this))
                        return subs_one_level(m, options);
                else
                        return *this;
@@ -592,7 +507,7 @@ ex container<C>::subs(const exmap & m, unsigned options) const
 }
 
 /** Compare two containers of the same type. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 int container<C>::compare_same_type(const basic & other) const
 {
        GINAC_ASSERT(is_a<container>(other));
@@ -611,7 +526,7 @@ int container<C>::compare_same_type(const basic & other) const
        return (it1 == it1end) ? (it2 == it2end ? 0 : -1) : 1;
 }
 
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 bool container<C>::is_equal_same_type(const basic & other) const
 {
        GINAC_ASSERT(is_a<container>(other));
@@ -631,7 +546,7 @@ bool container<C>::is_equal_same_type(const basic & other) const
 }
 
 /** Add element at front. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 container<C> & container<C>::prepend(const ex & b)
 {
        ensure_if_modifiable();
@@ -640,7 +555,7 @@ container<C> & container<C>::prepend(const ex & b)
 }
 
 /** Add element at back. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 container<C> & container<C>::append(const ex & b)
 {
        ensure_if_modifiable();
@@ -649,7 +564,7 @@ container<C> & container<C>::append(const ex & b)
 }
 
 /** Remove first element. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 container<C> & container<C>::remove_first()
 {
        ensure_if_modifiable();
@@ -658,7 +573,7 @@ container<C> & container<C>::remove_first()
 }
 
 /** Remove last element. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 container<C> & container<C>::remove_last()
 {
        ensure_if_modifiable();
@@ -667,7 +582,7 @@ container<C> & container<C>::remove_last()
 }
 
 /** Remove all elements. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 container<C> & container<C>::remove_all()
 {
        ensure_if_modifiable();
@@ -676,7 +591,7 @@ container<C> & container<C>::remove_all()
 }
 
 /** Sort elements. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 container<C> & container<C>::sort()
 {
        ensure_if_modifiable();
@@ -691,7 +606,7 @@ template<> inline void container<std::list>::unique_()
 }
 
 /** Remove adjacent duplicate elements. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 container<C> & container<C>::unique()
 {
        ensure_if_modifiable();
@@ -700,7 +615,7 @@ container<C> & container<C>::unique()
 }
 
 /** Print sequence of contained elements. */
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 void container<C>::printseq(const print_context & c, char openbracket, char delim,
                             char closebracket, unsigned this_precedence,
                             unsigned upper_precedence) const
@@ -723,28 +638,7 @@ void container<C>::printseq(const print_context & c, char openbracket, char deli
                c.s << closebracket;
 }
 
-template <template <class T, class = std::allocator<T> > class C>
-typename container<C>::STLT container<C>::evalchildren(int level) const
-{
-       if (level == 1)
-               return this->seq;
-       else if (level == -max_recursion_level)
-               throw std::runtime_error("max recursion level reached");
-
-       STLT s;
-       this->reserve(s, this->seq.size());
-
-       --level;
-       const_iterator it = this->seq.begin(), itend = this->seq.end();
-       while (it != itend) {
-               s.push_back(it->eval(level));
-               ++it;
-       }
-
-       return s;
-}
-
-template <template <class T, class = std::allocator<T> > class C>
+template <template <class T, class = std::allocator<T>> class C>
 typename container<C>::STLT container<C>::subschildren(const exmap & m, unsigned options) const
 {
        // returns an empty container if nothing had to be substituted