namespace GiNaC {
-GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(symbol, basic)
+GINAC_IMPLEMENT_REGISTERED_CLASS(symbol, basic)
//////////
// default ctor, dtor, copy ctor, assignment operator and helpers
TeX_name = other.TeX_name;
serial = other.serial;
asexinfop = other.asexinfop;
- ++asexinfop->refcount;
+ ++(asexinfop->refcount);
}
void symbol::destroy(bool call_parent)
// public
-symbol::symbol(const symbol & other)
-{
- copy(other);
-}
-
symbol::symbol(const std::string & initname) : inherited(TINFO_symbol)
{
name = initname;
// public
-basic *symbol::duplicate() const
-{
- return new symbol(*this);
-}
-
void symbol::print(const print_context & c, unsigned level) const
{
if (is_a<print_tree>(c)) {
* first place. */
class symbol : public basic
{
- GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(symbol, basic)
+ GINAC_DECLARE_REGISTERED_CLASS(symbol, basic)
// types
// member functions
- // default ctor, dtor, copy ctor, assignment operator and helpers
-public:
- symbol();
- ~symbol() { destroy(false); }
- symbol(const symbol & other);
-protected:
- void copy(const symbol & other);
- void destroy(bool call_parent);
-
// other ctors
public:
explicit symbol(const std::string & initname);
// functions overriding virtual functions from base classes
public:
- basic * duplicate() const;
void print(const print_context & c, unsigned level = 0) const;
bool info(unsigned inf) const;
ex eval(int level = 0) const;
ex to_rational(lst &repl_lst) const;
protected:
ex derivative(const symbol & s) const;
- int compare_same_type(const basic & other) const;
bool is_equal_same_type(const basic & other) const;
unsigned calchash(void) const;
try {
// minimal_dim() throws an exception when index dimensions are not comparable
ex min_dim = self_idx->minimal_dim(other_idx);
- *self = _ex1;
*other = other->subs(other_idx == free_idx->replace_dim(min_dim));
+ *self = _ex1; // *other is assigned first because assigning *self invalidates free_idx
return true;
} catch (std::exception &e) {
return false;
if (is_dummy_pair(*self_idx, other_idx)) {
// Contraction found, remove metric tensor and substitute
- // index in second object
- *self = (static_cast<const spinidx *>(self_idx)->is_covariant() ? sign : -sign);
+ // index in second object (assign *self last because this
+ // invalidates free_idx)
*other = other->subs(other_idx == *free_idx);
+ *self = (static_cast<const spinidx *>(self_idx)->is_covariant() ? sign : -sign);
return true;
}
}