]> www.ginac.de Git - ginac.git/blobdiff - ginac/ex.cpp
Improve method of setting status_flags::dynallocated.
[ginac.git] / ginac / ex.cpp
index 648283001d861b2547bd5b0a8a585f6102e263f4..7bd8410b6d4f50dc2751557bb41dcb3471efa51c 100644 (file)
@@ -401,10 +401,7 @@ basic & ex::construct_from_int(int i)
        case 12:
                return *const_cast<numeric *>(_num12_p);
        default:
-               basic *bp = new numeric(i);
-               bp->setflag(status_flags::dynallocated);
-               GINAC_ASSERT(bp->get_refcount() == 0);
-               return *bp;
+               return dynallocate<numeric>(i);
        }
 }
        
@@ -438,10 +435,7 @@ basic & ex::construct_from_uint(unsigned int i)
        case 12:
                return *const_cast<numeric *>(_num12_p);
        default:
-               basic *bp = new numeric(i);
-               bp->setflag(status_flags::dynallocated);
-               GINAC_ASSERT(bp->get_refcount() == 0);
-               return *bp;
+               return dynallocate<numeric>(i);
        }
 }
        
@@ -499,10 +493,7 @@ basic & ex::construct_from_long(long i)
        case 12:
                return *const_cast<numeric *>(_num12_p);
        default:
-               basic *bp = new numeric(i);
-               bp->setflag(status_flags::dynallocated);
-               GINAC_ASSERT(bp->get_refcount() == 0);
-               return *bp;
+               return dynallocate<numeric>(i);
        }
 }
        
@@ -536,19 +527,13 @@ basic & ex::construct_from_ulong(unsigned long i)
        case 12:
                return *const_cast<numeric *>(_num12_p);
        default:
-               basic *bp = new numeric(i);
-               bp->setflag(status_flags::dynallocated);
-               GINAC_ASSERT(bp->get_refcount() == 0);
-               return *bp;
+               return dynallocate<numeric>(i);
        }
 }
        
 basic & ex::construct_from_double(double d)
 {
-       basic *bp = new numeric(d);
-       bp->setflag(status_flags::dynallocated);
-       GINAC_ASSERT(bp->get_refcount() == 0);
-       return *bp;
+       return dynallocate<numeric>(d);
 }
 
 //////////