]> www.ginac.de Git - ginac.git/commitdiff
Remove 'discardable' option from ctors of container and derived classes.
authorRichard Kreckel <kreckel@ginac.de>
Sat, 7 Nov 2015 12:03:05 +0000 (13:03 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Sat, 7 Nov 2015 12:03:05 +0000 (13:03 +0100)
The whole idea of this was to allow the ctor to pilfer the data from the
constructed-from object, which is precisely the move semantics which
C++11 supports with rvalue references.

12 files changed:
ginac/clifford.cpp
ginac/clifford.h
ginac/color.cpp
ginac/color.h
ginac/container.h
ginac/function.cppy
ginac/function.hppy
ginac/indexed.cpp
ginac/indexed.h
ginac/ncmul.cpp
ginac/ncmul.h
ginac/power.cpp

index 16f83196668bd1161cf9f0b3ea52577842bf2682..56e43bd8e11ccad790003ee5a719fc074fcd5a66 100644 (file)
@@ -105,7 +105,7 @@ clifford::clifford(const ex & b, const ex & mu, const ex & metr, unsigned char r
        GINAC_ASSERT(is_a<idx>(mu));
 }
 
-clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl), metric(metr), commutator_sign(comm_sign)
+clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v) : inherited(not_symmetric(), v), representation_label(rl), metric(metr), commutator_sign(comm_sign)
 {
 }
 
@@ -399,7 +399,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
                        if (std::find_if(self + 1, other, is_not_a_clifford()) != other)
                                return false;
 
-                       *self = ncmul(exvector(std::reverse_iterator<exvector::const_iterator>(other), std::reverse_iterator<exvector::const_iterator>(self + 1)), true);
+                       *self = ncmul(exvector(std::reverse_iterator<exvector::const_iterator>(other), std::reverse_iterator<exvector::const_iterator>(self + 1)));
                        std::fill(self + 1, other, _ex1);
                        *other = _ex_2;
                        return true;
@@ -412,8 +412,8 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
                                return false;
 
                        exvector::iterator next_to_last = other - 1;
-                       ex S = ncmul(exvector(self + 1, next_to_last), true);
-                       ex SR = ncmul(exvector(std::reverse_iterator<exvector::const_iterator>(next_to_last), std::reverse_iterator<exvector::const_iterator>(self + 1)), true);
+                       ex S = ncmul(exvector(self + 1, next_to_last));
+                       ex SR = ncmul(exvector(std::reverse_iterator<exvector::const_iterator>(next_to_last), std::reverse_iterator<exvector::const_iterator>(self + 1)));
 
                        *self = (*next_to_last) * S + SR * (*next_to_last);
                        std::fill(self + 1, other, _ex1);
@@ -428,7 +428,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
                                return false;
 
                        exvector::iterator next_to_last = other - 1;
-                       ex S = ncmul(exvector(self + 1, next_to_last), true);
+                       ex S = ncmul(exvector(self + 1, next_to_last));
 
                        *self = 2 * (*next_to_last) * S - (*self) * S * (*other) * (*next_to_last);
                        std::fill(self + 1, other + 1, _ex1);
@@ -495,7 +495,7 @@ bool cliffordunit::contract_with(exvector::iterator self, exvector::iterator oth
                                return false;
                        }
                        
-                       ex S = ncmul(exvector(self + 1, before_other), true);
+                       ex S = ncmul(exvector(self + 1, before_other));
 
                        if (is_a<clifford>(*before_other) && ex_to<clifford>(*before_other).get_representation_label() == rl) {
                                *self = 2 * (*self) * S * unit.get_metric(alpha, mu_toggle, true) - (*self) * S * (*other) * (*before_other);
@@ -1063,7 +1063,7 @@ ex canonicalize_clifford(const ex & e_)
                                                ex sum = ncmul(v);
                                                it[0] = save1;
                                                it[1] = save0;
-                                               sum += ex_to<clifford>(save0).get_commutator_sign() * ncmul(v, true);
+                                               sum += ex_to<clifford>(save0).get_commutator_sign() * ncmul(std::move(v));
                                                i->second = canonicalize_clifford(sum);
                                                goto next_sym;
                                        }
index bb3a7fece47ea7e335ac28b47201a792414c2422..6af79dbc42142ede07120fca1381cefa2db21650 100644 (file)
@@ -46,7 +46,7 @@ public:
        clifford(const ex & b, const ex & mu,  const ex & metr, unsigned char rl = 0, int comm_sign = -1);
 
        // internal constructors
-       clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v, bool discardable = false);
+       clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v);
        clifford(unsigned char rl, const ex & metr, int comm_sign, exvector && v);
 
        // functions overriding virtual functions from base classes
index 1d006e495dc3421df2913e39cfc9d705ec4ddfd1..dcc106dacda8309fec7f86c90ed295225a9f805d 100644 (file)
@@ -86,7 +86,7 @@ color::color(const ex & b, const ex & i1, unsigned char rl) : inherited(b, i1),
 {
 }
 
-color::color(unsigned char rl, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl)
+color::color(unsigned char rl, const exvector & v) : inherited(not_symmetric(), v), representation_label(rl)
 {
 }
 
index e4a11e4a417c5f79397d270ec40703f75c40e6ea..460e7a9ddaded2be8117e3a302caeb428ea3a22f 100644 (file)
@@ -46,7 +46,7 @@ public:
        color(const ex & b, const ex & i1, unsigned char rl = 0);
 
        // internal constructors
-       color(unsigned char rl, const exvector & v, bool discardable = false);
+       color(unsigned char rl, const exvector & v);
        color(unsigned char rl, exvector && v);
        void archive(archive_node& n) const;
        void read_archive(const archive_node& n, lst& sym_lst);
index cca5c673780a2e69f20f962c0d482885ed6405fd..3c1ac47eb688356fcd740f93149c358b1959715b 100644 (file)
@@ -142,14 +142,10 @@ protected:
 
        // constructors
 public:
-       container(STLT const & s, bool discardable = false)
+       container(STLT const & s)
        {
                setflag(get_default_flags());
-
-               if (discardable)
-                       this->seq.swap(const_cast<STLT &>(s));
-               else
-                       this->seq = s;
+               this->seq = s;
        }
 
        explicit container(STLT && v)
index 0a521e11a19e333d3ca0b3769248815018de1a05..fb1d879192a4b0e1a42712f4776d5a730b1b0ca4 100644 (file)
@@ -242,8 +242,8 @@ function::function(unsigned ser, const exprseq & es) : exprseq(es), serial(ser)
        clearflag(status_flags::evaluated);
 }
 
-function::function(unsigned ser, const exvector & v, bool discardable) 
-  : exprseq(v,discardable), serial(ser)
+function::function(unsigned ser, const exvector & v)
+  : exprseq(v), serial(ser)
 {
 }
 
index a5605115164e97cd8e8982c1abb0790abb1dfea6..b7d7b0d1c1715b91871d4ec7ceaba78e8af86bd9 100644 (file)
@@ -222,7 +222,7 @@ public:
 ---
        // end of generated lines
        function(unsigned ser, const exprseq & es);
-       function(unsigned ser, const exvector & v, bool discardable = false);
+       function(unsigned ser, const exvector & v);
        function(unsigned ser, exvector && v);
        
        // functions overriding virtual functions from base classes
index 5e63d8944db9d7156e68f3d108af3d7f75869e13..55c9768d9445d3555ab6486a8267ec8b4d273605 100644 (file)
@@ -117,7 +117,7 @@ indexed::indexed(const symmetry & symm, const exprseq & es) : inherited(es), sym
 {
 }
 
-indexed::indexed(const symmetry & symm, const exvector & v, bool discardable) : inherited(v, discardable), symtree(symm)
+indexed::indexed(const symmetry & symm, const exvector & v) : inherited(v), symtree(symm)
 {
 }
 
@@ -874,7 +874,7 @@ contraction_done:
                                        // the product
                                        bool is_a_product = (is_exactly_a<mul>(*it1) || is_exactly_a<ncmul>(*it1)) &&
                                                            (is_exactly_a<mul>(*it2) || is_exactly_a<ncmul>(*it2));
-                                       ex r = (non_commutative ? ex(ncmul(v, true)) : ex(mul(v)));
+                                       ex r = (non_commutative ? ex(ncmul(std::move(v))) : ex(mul(std::move(v))));
 
                                        // If new expression is a product we can call this function again,
                                        // otherwise we need to pass argument to simplify_indexed() to be expanded
@@ -941,7 +941,7 @@ contraction_done:
 
        ex r;
        if (something_changed)
-               r = non_commutative ? ex(ncmul(v, true)) : ex(mul(v));
+               r = non_commutative ? ex(ncmul(std::move(v))) : ex(mul(std::move(v)));
        else
                r = e;
 
index f45f7431fe9e9f27659b0aec760a8c5b860651b0..2c4f551106c7cf66d1e62eb9d70c883afb169f6a 100644 (file)
@@ -138,7 +138,7 @@ public:
 
        // internal constructors
        indexed(const symmetry & symm, const exprseq & es);
-       indexed(const symmetry & symm, const exvector & v, bool discardable = false);
+       indexed(const symmetry & symm, const exvector & v);
        indexed(const symmetry & symm, exvector && v);
 
        // functions overriding virtual functions from base classes
index b37904bb76bd2dde96e48e8fa6bc6c5398b48a1a..d15d6ca8124cf671af50bc41e5beabcb52f94167 100644 (file)
@@ -80,7 +80,7 @@ ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3,
 {
 }
 
-ncmul::ncmul(const exvector & v, bool discardable) : inherited(v,discardable)
+ncmul::ncmul(const exvector & v) : inherited(v)
 {
 }
 
@@ -179,7 +179,7 @@ ex ncmul::expand(unsigned options) const
                        term[positions_of_adds[i]] = rename_dummy_indices_uniquely(va, expanded_seq[positions_of_adds[i]].op(k[i]), true);
                }
 
-               distrseq.push_back((new ncmul(term, true))->
+               distrseq.push_back((new ncmul(std::move(term)))->
                                    setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0)));
 
                // increment k[]
@@ -233,7 +233,7 @@ ex ncmul::coeff(const ex & s, int n) const
                // if a non-zero power of s is found, the resulting product will be 0
                for (auto & it : seq)
                        coeffseq.push_back(it.coeff(s,n));
-               return (new ncmul(std::move(coeffseq),1))->setflag(status_flags::dynallocated);
+               return (new ncmul(std::move(coeffseq)))->setflag(status_flags::dynallocated);
        }
                 
        bool coeff_found = false;
@@ -248,7 +248,7 @@ ex ncmul::coeff(const ex & s, int n) const
        }
 
        if (coeff_found)
-               return (new ncmul(std::move(coeffseq), 1))->setflag(status_flags::dynallocated);
+               return (new ncmul(std::move(coeffseq)))->setflag(status_flags::dynallocated);
        
        return _ex0;
 }
@@ -364,8 +364,8 @@ ex ncmul::eval(int level) const
                        else
                                noncommutativeseq.push_back(assocseq[i]);
                }
-               commutativeseq.push_back((new ncmul(noncommutativeseq,1))->setflag(status_flags::dynallocated));
-               return (new mul(commutativeseq))->setflag(status_flags::dynallocated);
+               commutativeseq.push_back((new ncmul(std::move(noncommutativeseq)))->setflag(status_flags::dynallocated));
+               return (new mul(std::move(commutativeseq)))->setflag(status_flags::dynallocated);
        }
                
        // ncmul(x1,y1,x2,y2) -> *(ncmul(x1,x2),ncmul(y1,y2))
@@ -480,7 +480,7 @@ ex ncmul::conjugate() const
                --i;
                ev.push_back(i->conjugate());
        }
-       return (new ncmul(std::move(ev), true))->setflag(status_flags::dynallocated).eval();
+       return (new ncmul(std::move(ev)))->setflag(status_flags::dynallocated).eval();
 }
 
 ex ncmul::real_part() const
index 8e68054a3dbc22a5aec134c37a186d3abc07f085..92bdbe88c0de943a6c28e62657af750c53eb515c 100644 (file)
@@ -49,7 +49,7 @@ public:
              const ex & f4, const ex & f5);
        ncmul(const ex & f1, const ex & f2, const ex & f3,
              const ex & f4, const ex & f5, const ex & f6);
-       ncmul(const exvector & v, bool discardable=false);
+       ncmul(const exvector & v);
        ncmul(exvector && v);
 
        // functions overriding virtual functions from base classes
index 491f2d332a86a181184d9abad1b2a97bea796de8..b12ff8a44299351bf082e8be20782059fcecc014 100644 (file)
@@ -571,7 +571,7 @@ ex power::eval(int level) const
                if (num_exponent->is_pos_integer() &&
                    ebasis.return_type() != return_types::commutative &&
                    !is_a<matrix>(ebasis)) {
-                       return ncmul(exvector(num_exponent->to_int(), ebasis), true);
+                       return ncmul(exvector(num_exponent->to_int(), ebasis));
                }
        }